From f956cb0f1f94923187804c772e099b9c8b9d76e5 Mon Sep 17 00:00:00 2001 From: Elizabeth Myers Date: Tue, 5 Apr 2016 05:39:59 -0500 Subject: [PATCH] Use rb_* versions of nonportable string functions --- authd/authd.c | 2 +- authd/res.c | 2 +- authd/reslib.c | 4 ++-- extensions/hurt.c | 2 +- extensions/umode_noctcp.c | 2 +- ircd/authproc.c | 2 +- ircd/cache.c | 4 ++-- ircd/capability.c | 2 +- ircd/ircd_lexer.l | 2 +- ircd/ircd_parser.y | 6 +++--- ircd/modules.c | 2 +- ircd/newconf.c | 38 +++++++++++++++++++------------------- ircd/parse.c | 2 +- ircd/privilege.c | 2 +- ircd/s_conf.c | 2 +- ircd/s_serv.c | 2 +- ircd/substitution.c | 2 +- modules/chm_noctcp.c | 2 +- modules/core/m_error.c | 2 +- modules/m_challenge.c | 2 +- modules/m_oper.c | 2 +- wsockd/wsockd.c | 24 +----------------------- 22 files changed, 44 insertions(+), 66 deletions(-) diff --git a/authd/authd.c b/authd/authd.c index 1f45e036..08cf8e79 100644 --- a/authd/authd.c +++ b/authd/authd.c @@ -208,7 +208,7 @@ main(int argc, char *argv[]) rb_set_time(); setup_signals(); - authd_option_handlers = rb_dictionary_create("authd options handlers", strcasecmp); + authd_option_handlers = rb_dictionary_create("authd options handlers", rb_strcasecmp); init_resolver(); init_providers(); diff --git a/authd/res.c b/authd/res.c index a71472da..6d6723f4 100644 --- a/authd/res.c +++ b/authd/res.c @@ -599,7 +599,7 @@ static int check_question(struct reslist *request, HEADER * header, char *buf, c sizeof(hostbuf)); if (n <= 0) return 0; - if (strcasecmp(hostbuf, request->queryname)) + if (rb_strcasecmp(hostbuf, request->queryname)) return 0; return 1; } diff --git a/authd/reslib.c b/authd/reslib.c index b3b43726..7771da6c 100644 --- a/authd/reslib.c +++ b/authd/reslib.c @@ -243,9 +243,9 @@ parse_resvconf(void) if ((p = strpbrk(arg, " \t")) != NULL) *p = '\0'; /* take the first word */ - if (strcasecmp(opt, "domain") == 0) + if (rb_strcasecmp(opt, "domain") == 0) rb_strlcpy(irc_domain, arg, sizeof(irc_domain)); - else if (strcasecmp(opt, "nameserver") == 0) + else if (rb_strcasecmp(opt, "nameserver") == 0) add_nameserver(arg); } diff --git a/extensions/hurt.c b/extensions/hurt.c index 08655721..9f6ee7ad 100644 --- a/extensions/hurt.c +++ b/extensions/hurt.c @@ -576,7 +576,7 @@ hurt_find_exact(const char *ip) { hurt = (hurt_t *) ptr->data; - if (!strcasecmp(ip, hurt->ip)) + if (!rb_strcasecmp(ip, hurt->ip)) return hurt; } diff --git a/extensions/umode_noctcp.c b/extensions/umode_noctcp.c index 12851366..bb1b6490 100644 --- a/extensions/umode_noctcp.c +++ b/extensions/umode_noctcp.c @@ -46,7 +46,7 @@ umode_noctcp_process(hook_data_privmsg_user *data) { return; } - if (data->target_p->umodes & user_modes['C'] && *data->text == '\001' && strncasecmp(data->text + 1, "ACTION", 6)) { + if (data->target_p->umodes & user_modes['C'] && *data->text == '\001' && rb_strncasecmp(data->text + 1, "ACTION", 6)) { sendto_one_numeric(data->source_p, ERR_CANNOTSENDTOUSER, form_str(ERR_CANNOTSENDTOUSER), data->target_p->name, "+C set"); data->approved = ERR_CANNOTSENDTOUSER; return; diff --git a/ircd/authproc.c b/ircd/authproc.c index b3e24ef1..2fe51e5d 100644 --- a/ircd/authproc.c +++ b/ircd/authproc.c @@ -117,7 +117,7 @@ start_authd(void) cid_clients = rb_dictionary_create("authd cid to uid mapping", rb_uint32cmp); if(bl_stats == NULL) - bl_stats = rb_dictionary_create("blacklist statistics", strcasecmp); + bl_stats = rb_dictionary_create("blacklist statistics", rb_strcasecmp); if(timeout_ev == NULL) timeout_ev = rb_event_addish("timeout_dead_authd_clients", timeout_dead_authd_clients, NULL, 1); diff --git a/ircd/cache.c b/ircd/cache.c index b5581f52..40b21dee 100644 --- a/ircd/cache.c +++ b/ircd/cache.c @@ -68,8 +68,8 @@ init_cache(void) oper_motd = cache_file(ircd_paths[IRCD_PATH_IRCD_OMOTD], "opers.motd", 0); memset(&links_cache_list, 0, sizeof(links_cache_list)); - help_dict_oper = rb_dictionary_create("oper help", strcasecmp); - help_dict_user = rb_dictionary_create("user help", strcasecmp); + help_dict_oper = rb_dictionary_create("oper help", rb_strcasecmp); + help_dict_user = rb_dictionary_create("user help", rb_strcasecmp); } /* diff --git a/ircd/capability.c b/ircd/capability.c index 2eb5c60e..618c127a 100644 --- a/ircd/capability.c +++ b/ircd/capability.c @@ -143,7 +143,7 @@ capability_index_create(const char *name) idx = rb_malloc(sizeof(struct CapabilityIndex)); idx->name = name; - idx->cap_dict = rb_dictionary_create(name, strcasecmp); + idx->cap_dict = rb_dictionary_create(name, rb_strcasecmp); idx->highest_bit = 1; rb_dlinkAdd(idx, &idx->node, &capability_indexes); diff --git a/ircd/ircd_lexer.l b/ircd/ircd_lexer.l index 7112cc30..3d7503d9 100644 --- a/ircd/ircd_lexer.l +++ b/ircd/ircd_lexer.l @@ -251,6 +251,6 @@ void hashcomment(void) if (strlen(yytext) < sizeof(INCLUDE) - 1) return; - if (!strncasecmp(yytext, INCLUDE, sizeof(INCLUDE) - 1)) + if (!rb_strncasecmp(yytext, INCLUDE, sizeof(INCLUDE) - 1)) yyerror("You probably meant '.include', skipping"); } diff --git a/ircd/ircd_parser.y b/ircd/ircd_parser.y index 900f5ea5..f07c3f9a 100644 --- a/ircd/ircd_parser.y +++ b/ircd/ircd_parser.y @@ -58,8 +58,8 @@ time_t conf_find_time(char *name) for (i = 0; ircd_times[i].name; i++) { - if (strcasecmp(ircd_times[i].name, name) == 0 || - (ircd_times[i].plural && strcasecmp(ircd_times[i].plural, name) == 0)) + if (rb_strcasecmp(ircd_times[i].name, name) == 0 || + (ircd_times[i].plural && rb_strcasecmp(ircd_times[i].plural, name) == 0)) return ircd_times[i].val; } @@ -86,7 +86,7 @@ static int conf_get_yesno_value(char *str) for (i = 0; yesno[i].word; i++) { - if (strcasecmp(str, yesno[i].word) == 0) + if (rb_strcasecmp(str, yesno[i].word) == 0) { return yesno[i].yesno; } diff --git a/ircd/modules.c b/ircd/modules.c index 36f91b62..d1c24990 100644 --- a/ircd/modules.c +++ b/ircd/modules.c @@ -255,7 +255,7 @@ load_all_modules(bool warn) size_t len = strlen(ldirent->d_name); if(len > module_ext_len && - strncasecmp(ldirent->d_name + (len - module_ext_len), LT_MODULE_EXT, module_ext_len) == 0) + rb_strncasecmp(ldirent->d_name + (len - module_ext_len), LT_MODULE_EXT, module_ext_len) == 0) { (void) snprintf(module_fq_name, sizeof(module_fq_name), "%s%c%s", ircd_paths[IRCD_PATH_AUTOLOAD_MODULES], RB_PATH_SEPARATOR, ldirent->d_name); diff --git a/ircd/newconf.c b/ircd/newconf.c index 240e88a6..d1585c1c 100644 --- a/ircd/newconf.c +++ b/ircd/newconf.c @@ -114,7 +114,7 @@ find_top_conf(const char *name) RB_DLINK_FOREACH(d, conf_items.head) { tc = d->data; - if(strcasecmp(tc->tc_name, name) == 0) + if(rb_strcasecmp(tc->tc_name, name) == 0) return tc; } @@ -136,7 +136,7 @@ find_conf_item(const struct TopConf *top, const char *name) { cf = &top->tc_entries[i]; - if(!strcasecmp(cf->cf_name, name)) + if(!rb_strcasecmp(cf->cf_name, name)) return cf; } } @@ -144,7 +144,7 @@ find_conf_item(const struct TopConf *top, const char *name) RB_DLINK_FOREACH(d, top->tc_items.head) { cf = d->data; - if(strcasecmp(cf->cf_name, name) == 0) + if(rb_strcasecmp(cf->cf_name, name) == 0) return cf; } @@ -1395,10 +1395,10 @@ conf_set_connect_aftype(void *data) { char *aft = data; - if(strcasecmp(aft, "ipv4") == 0) + if(rb_strcasecmp(aft, "ipv4") == 0) yy_server->aftype = AF_INET; #ifdef RB_IPV6 - else if(strcasecmp(aft, "ipv6") == 0) + else if(rb_strcasecmp(aft, "ipv6") == 0) yy_server->aftype = AF_INET6; #endif else @@ -1549,11 +1549,11 @@ conf_set_general_hide_error_messages(void *data) { char *val = data; - if(strcasecmp(val, "yes") == 0) + if(rb_strcasecmp(val, "yes") == 0) ConfigFileEntry.hide_error_messages = 2; - else if(strcasecmp(val, "opers") == 0) + else if(rb_strcasecmp(val, "opers") == 0) ConfigFileEntry.hide_error_messages = 1; - else if(strcasecmp(val, "no") == 0) + else if(rb_strcasecmp(val, "no") == 0) ConfigFileEntry.hide_error_messages = 0; else conf_report_error("Invalid setting '%s' for general::hide_error_messages.", val); @@ -1573,11 +1573,11 @@ conf_set_general_stats_k_oper_only(void *data) { char *val = data; - if(strcasecmp(val, "yes") == 0) + if(rb_strcasecmp(val, "yes") == 0) ConfigFileEntry.stats_k_oper_only = 2; - else if(strcasecmp(val, "masked") == 0) + else if(rb_strcasecmp(val, "masked") == 0) ConfigFileEntry.stats_k_oper_only = 1; - else if(strcasecmp(val, "no") == 0) + else if(rb_strcasecmp(val, "no") == 0) ConfigFileEntry.stats_k_oper_only = 0; else conf_report_error("Invalid setting '%s' for general::stats_k_oper_only.", val); @@ -1588,11 +1588,11 @@ conf_set_general_stats_i_oper_only(void *data) { char *val = data; - if(strcasecmp(val, "yes") == 0) + if(rb_strcasecmp(val, "yes") == 0) ConfigFileEntry.stats_i_oper_only = 2; - else if(strcasecmp(val, "masked") == 0) + else if(rb_strcasecmp(val, "masked") == 0) ConfigFileEntry.stats_i_oper_only = 1; - else if(strcasecmp(val, "no") == 0) + else if(rb_strcasecmp(val, "no") == 0) ConfigFileEntry.stats_i_oper_only = 0; else conf_report_error("Invalid setting '%s' for general::stats_i_oper_only.", val); @@ -1667,11 +1667,11 @@ conf_set_general_certfp_method(void *data) { char *method = data; - if (!strcasecmp(method, "sha1")) + if (!rb_strcasecmp(method, "sha1")) ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SHA1; - else if (!strcasecmp(method, "sha256")) + else if (!rb_strcasecmp(method, "sha256")) ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SHA256; - else if (!strcasecmp(method, "sha512")) + else if (!rb_strcasecmp(method, "sha512")) ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SHA512; else { @@ -1884,9 +1884,9 @@ conf_set_blacklist_type(void *data) for (; args; args = args->next) { - if (!strcasecmp(args->v.string, "ipv4")) + if (!rb_strcasecmp(args->v.string, "ipv4")) yy_blacklist_iptype |= IPTYPE_IPV4; - else if (!strcasecmp(args->v.string, "ipv6")) + else if (!rb_strcasecmp(args->v.string, "ipv6")) yy_blacklist_iptype |= IPTYPE_IPV6; else conf_report_error("blacklist::type has unknown address family %s", diff --git a/ircd/parse.c b/ircd/parse.c index 74c5fddb..738bb753 100644 --- a/ircd/parse.c +++ b/ircd/parse.c @@ -295,7 +295,7 @@ handle_encap(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *so void clear_hash_parse() { - cmd_dict = rb_dictionary_create("command", strcasecmp); + cmd_dict = rb_dictionary_create("command", rb_strcasecmp); } /* mod_add_cmd diff --git a/ircd/privilege.c b/ircd/privilege.c index b0d8a0d2..d81bf8f3 100644 --- a/ircd/privilege.c +++ b/ircd/privilege.c @@ -51,7 +51,7 @@ privilegeset_get_any(const char *name) { struct PrivilegeSet *set = (struct PrivilegeSet *) iter->data; - if (!strcasecmp(set->name, name)) + if (!rb_strcasecmp(set->name, name)) return set; } diff --git a/ircd/s_conf.c b/ircd/s_conf.c index 10d11bec..19ea9fd0 100644 --- a/ircd/s_conf.c +++ b/ircd/s_conf.c @@ -814,7 +814,7 @@ set_default_conf(void) ConfigFileEntry.hide_opers_in_whois = 0; if (!alias_dict) - alias_dict = rb_dictionary_create("alias", strcasecmp); + alias_dict = rb_dictionary_create("alias", rb_strcasecmp); } /* diff --git a/ircd/s_serv.c b/ircd/s_serv.c index 1c49baa5..4b449323 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.c @@ -397,7 +397,7 @@ check_server(const char *name, struct Client *client_p) if(tmp_p->certfp) { - if(!client_p->certfp || strcasecmp(tmp_p->certfp, client_p->certfp) != 0) + if(!client_p->certfp || rb_strcasecmp(tmp_p->certfp, client_p->certfp) != 0) continue; } diff --git a/ircd/substitution.c b/ircd/substitution.c index eb27288d..593bbd1d 100644 --- a/ircd/substitution.c +++ b/ircd/substitution.c @@ -135,7 +135,7 @@ char *substitution_parse(const char *fmt, rb_dlink_list *varlist) { struct substitution_variable *val = (struct substitution_variable *) nptr->data; - if (!strcasecmp(varname, val->name)) + if (!rb_strcasecmp(varname, val->name)) { rb_strlcpy(bptr, val->value, BUFSIZE - (bptr - buf)); bptr += strlen(val->value); diff --git a/modules/chm_noctcp.c b/modules/chm_noctcp.c index d4d990c1..60e4f7d5 100644 --- a/modules/chm_noctcp.c +++ b/modules/chm_noctcp.c @@ -53,7 +53,7 @@ chm_noctcp_process(hook_data_privmsg_channel *data) if (data->approved || data->msgtype == MESSAGE_TYPE_NOTICE) return; - if (*data->text == '\001' && strncasecmp(data->text + 1, "ACTION ", 7) && data->chptr->mode.mode & mode_noctcp) + if (*data->text == '\001' && rb_strncasecmp(data->text + 1, "ACTION ", 7) && data->chptr->mode.mode & mode_noctcp) { sendto_one_numeric(data->source_p, ERR_CANNOTSENDTOCHAN, form_str(ERR_CANNOTSENDTOCHAN), data->chptr->chname); data->approved = ERR_CANNOTSENDTOCHAN; diff --git a/modules/core/m_error.c b/modules/core/m_error.c index d8a93148..4ef16881 100644 --- a/modules/core/m_error.c +++ b/modules/core/m_error.c @@ -67,7 +67,7 @@ is_safe_error(const char *message) if (!strncmp(message, "Terminated by ", 14)) return true; - if (!strncasecmp(message, "Closing Link", 12)) + if (!rb_strncasecmp(message, "Closing Link", 12)) return false; if (strchr(message, '[')) return false; diff --git a/modules/m_challenge.c b/modules/m_challenge.c index 6dcc16c9..d9a285ac 100644 --- a/modules/m_challenge.c +++ b/modules/m_challenge.c @@ -240,7 +240,7 @@ m_challenge(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou if (oper_p->certfp != NULL) { - if (source_p->certfp == NULL || strcasecmp(source_p->certfp, oper_p->certfp)) + if (source_p->certfp == NULL || rb_strcasecmp(source_p->certfp, oper_p->certfp)) { sendto_one_numeric(source_p, ERR_NOOPERHOST, form_str(ERR_NOOPERHOST)); ilog(L_FOPER, "FAILED OPER (%s) by (%s!%s@%s) (%s) -- client certificate fingerprint mismatch", diff --git a/modules/m_oper.c b/modules/m_oper.c index 926af3fd..9afef1f8 100644 --- a/modules/m_oper.c +++ b/modules/m_oper.c @@ -117,7 +117,7 @@ m_oper(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p if (oper_p->certfp != NULL) { - if (source_p->certfp == NULL || strcasecmp(source_p->certfp, oper_p->certfp)) + if (source_p->certfp == NULL || rb_strcasecmp(source_p->certfp, oper_p->certfp)) { sendto_one_numeric(source_p, ERR_NOOPERHOST, form_str(ERR_NOOPERHOST)); ilog(L_FOPER, "FAILED OPER (%s) by (%s!%s@%s) (%s) -- client certificate fingerprint mismatch", diff --git a/wsockd/wsockd.c b/wsockd/wsockd.c index 2414a886..1ab3120c 100644 --- a/wsockd/wsockd.c +++ b/wsockd/wsockd.c @@ -156,28 +156,6 @@ ws_frame_set_fin(ws_frame_hdr_t *header, int fin) header->opcode_rsv_fin |= (fin << 7) & (0x1 << 7); } -#ifdef _WIN32 -char * -strcasestr(const char *s, const char *find) -{ - char c, sc; - size_t len; - - if ((c = *find++) != 0) { - c = tolower((unsigned char)c); - len = strlen(find); - do { - do { - if ((sc = *s++) == 0) - return (NULL); - } while ((char)tolower((unsigned char)sc) != c); - } while (strnicmp(s, find, len) != 0); - s--; - } - return ((char *)s); -} -#endif - static void close_conn(conn_t * conn, int wait_plain, const char *fmt, ...); static void conn_mod_read_cb(rb_fde_t *fd, void *data); static void conn_plain_read_cb(rb_fde_t *fd, void *data); @@ -682,7 +660,7 @@ conn_mod_handshake_process(conn_t *conn) if (!dolen) break; - if ((p = strcasestr(inbuf, "Sec-WebSocket-Key:")) != NULL) + if ((p = rb_strcasestr(inbuf, "Sec-WebSocket-Key:")) != NULL) { char *start, *end;