fixup buffers referring to MAXHOST

This commit is contained in:
Mark 2003-12-17 18:05:25 +00:00
parent 0a44475104
commit 1c3f7a5ac5
3 changed files with 17 additions and 14 deletions

View file

@ -2,6 +2,7 @@ Open Proxy Scanning Bot Module for NeoStats Changelog.
============================================================================== ==============================================================================
* Version 2.0 * 29/12/2003 * Fish (F) and Mark (M) * Version 2.0 * 29/12/2003 * Fish (F) and Mark (M)
- Fixed incorrect parameters to printf style functions (M) - Fixed incorrect parameters to printf style functions (M)
- Use more appropriate defines for buffer sizes since MAXHOST differs between IRCds (M)
* Version 2.0 * 29/12/2003 * Fish (F) and Mark (M) * Version 2.0 * 29/12/2003 * Fish (F) and Mark (M)
- Some segv updates from M (mark@ctcp.net) (M/F) - Some segv updates from M (mark@ctcp.net) (M/F)

26
opsb.c
View file

@ -693,7 +693,7 @@ int do_set(User *u, char **av, int ac) {
return 0; return 0;
} }
int Online(char **av, int ac) { static int Online(char **av, int ac) {
struct sockaddr_in sa; struct sockaddr_in sa;
socklen_t ulen = sizeof(struct sockaddr_in); socklen_t ulen = sizeof(struct sockaddr_in);
@ -729,28 +729,28 @@ void unconf() {
void save_ports() { void save_ports() {
lnode_t *pn; lnode_t *pn;
port_list *pl; port_list *pl;
char confpath[MAXHOST]; char confpath[CONFBUFSIZE];
char ports[MAXHOST]; char ports[CONFBUFSIZE];
char tmpports[MAXHOST]; char tmpports[CONFBUFSIZE];
int lasttype = -1; int lasttype = -1;
pn = list_first(opsb.ports); pn = list_first(opsb.ports);
while (pn) { while (pn) {
pl = lnode_get(pn); pl = lnode_get(pn);
/* if the port is different from the last round, and its not the first round, save it */ /* if the port is different from the last round, and its not the first round, save it */
if ((pl->type != lasttype) && (lasttype != -1)) { if ((pl->type != lasttype) && (lasttype != -1)) {
strlcpy(confpath, type_of_proxy(lasttype), MAXHOST); strlcpy(confpath, type_of_proxy(lasttype), CONFBUFSIZE);
SetConf((void *)ports, CFGSTR, confpath); SetConf((void *)ports, CFGSTR, confpath);
} }
if (pl->type != lasttype) { if (pl->type != lasttype) {
ircsnprintf(ports, MAXHOST, "%d", pl->port); ircsnprintf(ports, CONFBUFSIZE, "%d", pl->port);
} else { } else {
ircsnprintf(tmpports, MAXHOST, "%s %d", ports, pl->port); ircsnprintf(tmpports, CONFBUFSIZE, "%s %d", ports, pl->port);
strlcpy(ports, tmpports, MAXHOST); strlcpy(ports, tmpports, CONFBUFSIZE);
} }
lasttype = pl->type; lasttype = pl->type;
pn = list_next(opsb.ports, pn); pn = list_next(opsb.ports, pn);
} }
strlcpy(confpath, type_of_proxy(lasttype), MAXHOST); strlcpy(confpath, type_of_proxy(lasttype), CONFBUFSIZE);
SetConf((void *)ports, CFGSTR, confpath); SetConf((void *)ports, CFGSTR, confpath);
flush_keeper(); flush_keeper();
} }
@ -1243,7 +1243,7 @@ void LoadConfig(void)
exempts = malloc(sizeof(exemptinfo)); exempts = malloc(sizeof(exemptinfo));
strlcpy(exempts->host, data[i], MAXHOST); strlcpy(exempts->host, data[i], MAXHOST);
ircsnprintf(datapath, MAXHOST, "Exempt/%s/Who", data[i]); ircsnprintf(datapath, CONFBUFSIZE, "Exempt/%s/Who", data[i]);
if (GetConf((void *)&tmp, CFGSTR, datapath) <= 0) { if (GetConf((void *)&tmp, CFGSTR, datapath) <= 0) {
free(exempts); free(exempts);
continue; continue;
@ -1251,15 +1251,15 @@ void LoadConfig(void)
strlcpy(exempts->who, tmp, MAXNICK); strlcpy(exempts->who, tmp, MAXNICK);
free(tmp); free(tmp);
} }
ircsnprintf(datapath, MAXHOST, "Exempt/%s/Reason", data[i]); ircsnprintf(datapath, CONFBUFSIZE, "Exempt/%s/Reason", data[i]);
if (GetConf((void *)&tmp, CFGSTR, datapath) <= 0) { if (GetConf((void *)&tmp, CFGSTR, datapath) <= 0) {
free(exempts); free(exempts);
continue; continue;
} else { } else {
strlcpy(exempts->reason, tmp, MAXHOST); strlcpy(exempts->reason, tmp, MAXREASON);
free(tmp); free(tmp);
} }
ircsnprintf(datapath, MAXHOST, "Exempt/%s/Server", data[i]); ircsnprintf(datapath, CONFBUFSIZE, "Exempt/%s/Server", data[i]);
if (GetConf((void *)&exempts->server, CFGINT, datapath) <= 0) { if (GetConf((void *)&exempts->server, CFGINT, datapath) <= 0) {
free(exempts); free(exempts);
continue; continue;

4
opsb.h
View file

@ -34,6 +34,8 @@ extern char s_opsb[MAXNICK];
/* max no of ports to scan */ /* max no of ports to scan */
#define MAX_PORTS 50 #define MAX_PORTS 50
#define MAXREASON 128
struct scanq { struct scanq {
char who[MAXHOST]; char who[MAXHOST];
int state; int state;
@ -98,7 +100,7 @@ struct exempts {
char host[MAXHOST]; char host[MAXHOST];
int server; int server;
char who[MAXNICK]; char who[MAXNICK];
char reason[MAXHOST]; char reason[MAXREASON];
}; };
typedef struct exempts exemptinfo; typedef struct exempts exemptinfo;