From fed61efcdb54af849fdfbec2f3bf5a875cfb65e2 Mon Sep 17 00:00:00 2001 From: codemastr Date: Sat, 11 Jan 2003 19:33:42 +0000 Subject: [PATCH] Misc. fixes --- Changes | 1 + include/h.h | 2 ++ src/match.c | 13 ++++++++++--- src/modules/scan.c | 7 ++++--- src/random.c | 13 ++----------- src/s_conf.c | 13 ++++++++----- 6 files changed, 27 insertions(+), 22 deletions(-) diff --git a/Changes b/Changes index 24284853e..4316179eb 100644 --- a/Changes +++ b/Changes @@ -1765,3 +1765,4 @@ seen. gmtime warning still there is specified as encrypted. (#0000597) - Fixed bug #0000601 reported by cate where specifying just a :port number for set::scan::endpoint caused a seg fault. +- Added some patches by Syzop to fix a variety of different bugs diff --git a/include/h.h b/include/h.h index 5283c99ef..f77536cd7 100644 --- a/include/h.h +++ b/include/h.h @@ -325,6 +325,7 @@ extern int parse(aClient *, char *, char *); extern int do_numeric(int, aClient *, aClient *, int, char **); extern int hunt_server(aClient *, aClient *, char *, int, int, char **); extern int hunt_server_token(aClient *, aClient *, char *, char *, char *, int, int, char **); +extern int hunt_server_token_quiet(aClient *, aClient *, char *, char *, char *, int, int, char **); extern aClient *next_client(aClient *, char *); extern int m_umode(aClient *, aClient *, int, char **); extern int m_names(aClient *, aClient *, int, char **); @@ -525,6 +526,7 @@ extern u_long cres_mem(aClient *sptr, char *nick); extern void flag_add(char *ch); extern void flag_del(char ch); extern void init_dynconf(void); +extern char *pretty_time_val(long); extern int init_conf(char *filename, int rehash); extern void validate_configuration(void); extern void run_configuration(void); diff --git a/src/match.c b/src/match.c index ba696b12a..b71424f6f 100644 --- a/src/match.c +++ b/src/match.c @@ -67,6 +67,10 @@ static inline int match2(char *mask, char *name) } else if (cm != '?' && lc(cm) != lc(*n)) return 1; /* most likely first chars won't match */ + else if ((*m == '\0') && (*n == '\0')) + return 0; /* true: both are empty */ + else if (*n == '\0') + return 1; /* false: name is empty */ else { m++; @@ -98,6 +102,8 @@ static inline int match2(char *mask, char *name) do { m++; /* go to the next char of both */ + if (!*n) + return 1; /* false: no character left */ n++; if (!*n) /* if end of test string... */ return (!*m ? 0 : 1); /* true if end of mask str, else false */ @@ -110,9 +116,9 @@ static inline int match2(char *mask, char *name) cm = lc(cm); while (lc(*n) != cm) { /* compare */ - n++; /* go to next char of n */ if (!*n) /* if at end of n string */ return 1; /* function becomes false. */ + n++; /* go to next char of n */ } wsm = m; /* mark after where wildcard found */ cm = lc(*(++m)); /* go to next mask char */ @@ -123,6 +129,8 @@ static inline int match2(char *mask, char *name) if (cm == '?') /* found ? wildcard */ { cm = lc(*(++m)); /* just skip and go to next */ + if (!*n) + return 1; /* false: no character left */ n++; if (!*n) /* return true if end of both, */ return (cm ? 1 : 0); /* false if end of test str only */ @@ -131,7 +139,6 @@ static inline int match2(char *mask, char *name) if (cm == '\\') /* next char will not be a wildcard. */ { /* skip wild checking, don't continue */ cm = lc(*(++m)); - n++; } /* Complicated to read, but to save CPU time. Every ounce counts. */ if (lc(*n) != cm) /* if the current chars don't equal, */ @@ -143,9 +150,9 @@ static inline int match2(char *mask, char *name) cm = lc(*m); while (cm != lc(*n)) { /* compare them */ - n++; /* go to next char of n */ if (!*n) /* if we reached end of n string, */ return 1; /* function becomes false. */ + n++; /* go to next char of n */ } wsn = n; /* mark spot first char was found */ } diff --git a/src/modules/scan.c b/src/modules/scan.c index b0aa6ccae..247ec197f 100644 --- a/src/modules/scan.c +++ b/src/modules/scan.c @@ -199,7 +199,7 @@ int Scan_IsBeingChecked(struct IN_ADDR *ia) IRCMutexLock(Scannings_lock); for (sr = Scannings; sr; sr = sr->next) { - if (!bcmp(&sr->in, ia, sizeof(Scan_AddrStruct))) + if (!bcmp(&sr->in, ia, sizeof(struct IN_ADDR))) { ret = 1; break; @@ -347,7 +347,7 @@ DLLFUNC int h_scan_connect(aClient *sptr) * }; * */ -DLLFUNC h_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs) { +DLLFUNC int h_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs) { ConfigEntry *cep; int errors = 0; @@ -439,7 +439,7 @@ DLLFUNC h_config_test(ConfigFile *cf, ConfigEntry *ce, int type, int *errs) { return 0; } -DLLFUNC h_config_run(ConfigFile *cf, ConfigEntry *ce, int type) { +DLLFUNC int h_config_run(ConfigFile *cf, ConfigEntry *ce, int type) { ConfigEntry *cep; int errors = 0; @@ -515,6 +515,7 @@ DLLFUNC int h_config_rehash() { if (scan_message) MyFree(scan_message); + return 1; } DLLFUNC int h_stats_scan(aClient *sptr, char *stats) { diff --git a/src/random.c b/src/random.c index 20ee27e4c..368da47ac 100644 --- a/src/random.c +++ b/src/random.c @@ -135,20 +135,11 @@ struct _timeb nowt; /* Grab OS specific "random" data */ #ifndef _WIN32 gettimeofday(&nowt, NULL); - fd = open("/dev/random", O_RDONLY); + fd = open("/dev/urandom", O_RDONLY); if (fd) { (void)read(fd, &xrnd, sizeof(int)); - Debug((DEBUG_INFO, "init_random: read from /dev/random: 0x%.8x", xrnd)); + Debug((DEBUG_INFO, "init_random: read from /dev/urandom: 0x%.8x", xrnd)); close(fd); - } else { - fd = open("/dev/urandom", O_RDONLY); - if (fd) { - (void)read(fd, &xrnd, sizeof(int)); - Debug((DEBUG_INFO, "init_random: read from /dev/urandom: 0x%.8x", xrnd)); - close(fd); - } else { - Debug((DEBUG_INFO, "init_random: [BAD] nothing read from random devices")); - } } #else _ftime(&nowt); diff --git a/src/s_conf.c b/src/s_conf.c index c75cc8dfb..459ce160f 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -392,7 +392,7 @@ void ipport_seperate(char *string, char **ip, char **port) /* handle ipv6 type of ip address */ if (*string == '[') { - if (f = strrchr(string, ']')) + if ((f = strrchr(string, ']'))) { *ip = string + 1; /* skip [ */ *f = '\0'; /* terminate the ip string */ @@ -404,7 +404,7 @@ void ipport_seperate(char *string, char **ip, char **port) } } /* handle ipv4 and port */ - else if (f = strchr(string, ':')) + else if ((f = strchr(string, ':'))) { /* we found a colon... we may have ip:port or just :port */ if (f == string) @@ -532,7 +532,8 @@ tolower(*(text+1)) == 'n') || *text == '1' || tolower(*text) == 't') { break; } ret += atoi(sz+1)*mfactor; - + if (*text == '\0') + break; } } mfactor = 1; @@ -1033,6 +1034,8 @@ void free_iConf(aConfiguration *i) ircfree(i->network.x_stats_server); } +int config_test(); + int init_conf(char *rootconf, int rehash) { ConfigItem_include *inc, *next; @@ -4027,8 +4030,8 @@ int _test_badword(ConfigFile *conf, ConfigEntry *ce) { else { - int errorcode, errorbufsize, regex; - char *errorbuf, *tmp, *tmpbuf; + int errorcode, errorbufsize, regex=0; + char *errorbuf, *tmp, *tmpbuf=NULL; for (tmp = word->ce_vardata; *tmp; tmp++) { if ((int)*tmp < 65 || (int)*tmp > 123) { regex = 1;