From 907468c485f837cb8442c32509c8efec8f3f43b1 Mon Sep 17 00:00:00 2001 From: Valery Yatsko Date: Sun, 20 Apr 2008 08:40:40 +0400 Subject: [PATCH] strlcpy -> rb_strlcpy --- extensions/ip_cloaking.c | 6 +++--- extensions/ip_cloaking_old.c | 6 +++--- extensions/m_identify.c | 2 +- extensions/m_webirc.c | 6 +++--- include/irc_string.h | 4 ---- modules/core/m_join.c | 4 ++-- modules/core/m_message.c | 2 +- modules/core/m_nick.c | 30 +++++++++++++++--------------- modules/core/m_part.c | 2 +- modules/core/m_server.c | 14 +++++++------- modules/m_cap.c | 4 ++-- modules/m_challenge.c | 2 +- modules/m_chghost.c | 2 +- modules/m_dline.c | 6 +++--- modules/m_etrace.c | 2 +- modules/m_kline.c | 6 +++--- modules/m_pong.c | 2 +- modules/m_resv.c | 2 +- modules/m_sasl.c | 2 +- modules/m_scan.c | 2 +- modules/m_services.c | 4 ++-- modules/m_set.c | 4 ++-- modules/m_signon.c | 20 ++++++++++---------- modules/m_testline.c | 8 ++++---- modules/m_user.c | 4 ++-- modules/m_xline.c | 2 +- src/blacklist.c | 6 +++--- src/channel.c | 6 +++--- src/chmode.c | 6 +++--- src/client.c | 4 ++-- src/irc_string.c | 30 ------------------------------ src/ircd.c | 8 ++++---- src/listener.c | 2 +- src/res.c | 8 ++++---- src/reslib.c | 2 +- src/s_auth.c | 2 +- src/s_conf.c | 14 +++++++------- src/s_newconf.c | 4 ++-- src/s_serv.c | 6 +++--- src/s_user.c | 16 ++++++++-------- src/scache.c | 4 ++-- src/substitution.c | 2 +- src/whowas.c | 2 +- 43 files changed, 118 insertions(+), 152 deletions(-) diff --git a/extensions/ip_cloaking.c b/extensions/ip_cloaking.c index 1b5af63..6311731 100644 --- a/extensions/ip_cloaking.c +++ b/extensions/ip_cloaking.c @@ -175,7 +175,7 @@ check_umode_change(void *vdata) } if (strcmp(source_p->host, source_p->localClient->mangledhost)) { - strlcpy(source_p->host, source_p->localClient->mangledhost, HOSTLEN); + rb_strlcpy(source_p->host, source_p->localClient->mangledhost, HOSTLEN); distribute_hostchange(source_p); } else /* not really nice, but we need to send this numeric here */ @@ -187,7 +187,7 @@ check_umode_change(void *vdata) if (source_p->localClient->mangledhost != NULL && !strcmp(source_p->host, source_p->localClient->mangledhost)) { - strlcpy(source_p->host, source_p->orighost, HOSTLEN); + rb_strlcpy(source_p->host, source_p->orighost, HOSTLEN); distribute_hostchange(source_p); } } @@ -212,7 +212,7 @@ check_new_user(void *vdata) source_p->umodes &= ~user_modes['h']; if (source_p->umodes & user_modes['h']) { - strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host)); + rb_strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host)); if (irccmp(source_p->host, source_p->orighost)) SetDynSpoof(source_p); } diff --git a/extensions/ip_cloaking_old.c b/extensions/ip_cloaking_old.c index c87d7a2..6c186b6 100644 --- a/extensions/ip_cloaking_old.c +++ b/extensions/ip_cloaking_old.c @@ -131,7 +131,7 @@ check_umode_change(void *vdata) } if (strcmp(source_p->host, source_p->localClient->mangledhost)) { - strlcpy(source_p->host, source_p->localClient->mangledhost, HOSTLEN); + rb_strlcpy(source_p->host, source_p->localClient->mangledhost, HOSTLEN); distribute_hostchange(source_p); } else /* not really nice, but we need to send this numeric here */ @@ -143,7 +143,7 @@ check_umode_change(void *vdata) if (source_p->localClient->mangledhost != NULL && !strcmp(source_p->host, source_p->localClient->mangledhost)) { - strlcpy(source_p->host, source_p->orighost, HOSTLEN); + rb_strlcpy(source_p->host, source_p->orighost, HOSTLEN); distribute_hostchange(source_p); } } @@ -168,7 +168,7 @@ check_new_user(void *vdata) source_p->umodes &= ~user_modes['h']; if (source_p->umodes & user_modes['h']) { - strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host)); + rb_strlcpy(source_p->host, source_p->localClient->mangledhost, sizeof(source_p->host)); if (irccmp(source_p->host, source_p->orighost)) SetDynSpoof(source_p); } diff --git a/extensions/m_identify.c b/extensions/m_identify.c index ea4b75a..f74921c 100644 --- a/extensions/m_identify.c +++ b/extensions/m_identify.c @@ -68,7 +68,7 @@ char *reconstruct_parv(int parc, const char *parv[]) { static char tmpbuf[BUFSIZE]; int i; - strlcpy(tmpbuf, parv[0], BUFSIZE); + rb_strlcpy(tmpbuf, parv[0], BUFSIZE); for (i = 1; i < parc; i++) { strlcat(tmpbuf, " ", BUFSIZE); diff --git a/extensions/m_webirc.c b/extensions/m_webirc.c index 24fe297..050d699 100644 --- a/extensions/m_webirc.c +++ b/extensions/m_webirc.c @@ -118,12 +118,12 @@ mr_webirc(struct Client *client_p, struct Client *source_p, int parc, const char } - strlcpy(source_p->sockhost, parv[4], sizeof(source_p->sockhost)); + rb_strlcpy(source_p->sockhost, parv[4], sizeof(source_p->sockhost)); if(strlen(parv[3]) <= HOSTLEN) - strlcpy(source_p->host, parv[3], sizeof(source_p->host)); + rb_strlcpy(source_p->host, parv[3], sizeof(source_p->host)); else - strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host)); + rb_strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host)); del_unknown_ip(source_p); inetpton_sock(parv[4], (struct sockaddr *)&source_p->localClient->ip); diff --git a/include/irc_string.h b/include/irc_string.h index 8f348b6..123c8b6 100644 --- a/include/irc_string.h +++ b/include/irc_string.h @@ -91,10 +91,6 @@ int inetpton(int af, const char *src, void *dst); const char *inetntop_sock(struct sockaddr *src, char *dst, unsigned int size); int inetpton_sock(const char *src, struct sockaddr *dst); -#ifndef HAVE_STRLCPY -size_t strlcpy(char *dst, const char *src, size_t siz); -#endif - #ifndef HAVE_STRLCAT size_t strlcat(char *dst, const char *src, size_t siz); #endif diff --git a/modules/core/m_join.c b/modules/core/m_join.c index d4b1036..2d62410 100644 --- a/modules/core/m_join.c +++ b/modules/core/m_join.c @@ -624,7 +624,7 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char mode.mode |= MODE_DISFORWARD; break; case 'f': - strlcpy(mode.forward, parv[4 + args], sizeof(mode.forward)); + rb_strlcpy(mode.forward, parv[4 + args], sizeof(mode.forward)); args++; if(parc < 5 + args) return 0; @@ -638,7 +638,7 @@ ms_sjoin(struct Client *client_p, struct Client *source_p, int parc, const char return 0; break; case 'k': - strlcpy(mode.key, parv[4 + args], sizeof(mode.key)); + rb_strlcpy(mode.key, parv[4 + args], sizeof(mode.key)); args++; if(parc < 5 + args) return 0; diff --git a/modules/core/m_message.c b/modules/core/m_message.c index 2a21973..7eb2206 100644 --- a/modules/core/m_message.c +++ b/modules/core/m_message.c @@ -451,7 +451,7 @@ msg_channel(int p_or_n, const char *command, if(chptr->mode.mode & MODE_NOCOLOR) { - strlcpy(text2, text, BUFSIZE); + rb_strlcpy(text2, text, BUFSIZE); strip_colour(text2); text = text2; if (EmptyString(text)) diff --git a/modules/core/m_nick.c b/modules/core/m_nick.c index a87b436..dd827b8 100644 --- a/modules/core/m_nick.c +++ b/modules/core/m_nick.c @@ -139,7 +139,7 @@ mr_nick(struct Client *client_p, struct Client *source_p, int parc, const char * *s = '\0'; /* copy the nick and terminate it */ - strlcpy(nick, parv[1], sizeof(nick)); + rb_strlcpy(nick, parv[1], sizeof(nick)); /* check the nickname is ok */ if(!clean_nick(nick, 1)) @@ -203,7 +203,7 @@ m_nick(struct Client *client_p, struct Client *source_p, int parc, const char *p flood_endgrace(source_p); /* terminate nick to NICKLEN, we dont want clean_nick() to error! */ - strlcpy(nick, parv[1], sizeof(nick)); + rb_strlcpy(nick, parv[1], sizeof(nick)); /* check the nickname is ok */ if(!clean_nick(nick, 1)) @@ -724,7 +724,7 @@ set_initial_nick(struct Client *client_p, struct Client *source_p, char *nick) if(source_p->flags & FLAGS_SENTUSER) { - strlcpy(buf, source_p->username, sizeof(buf)); + rb_strlcpy(buf, source_p->username, sizeof(buf)); /* got user, heres nick. */ register_local_user(client_p, source_p, buf); @@ -1173,35 +1173,35 @@ register_client(struct Client *client_p, struct Client *server, source_p->tsinfo = newts; strcpy(source_p->name, nick); - strlcpy(source_p->username, parv[5], sizeof(source_p->username)); - strlcpy(source_p->host, parv[6], sizeof(source_p->host)); - strlcpy(source_p->orighost, source_p->host, sizeof(source_p->orighost)); + rb_strlcpy(source_p->username, parv[5], sizeof(source_p->username)); + rb_strlcpy(source_p->host, parv[6], sizeof(source_p->host)); + rb_strlcpy(source_p->orighost, source_p->host, sizeof(source_p->orighost)); if(parc == 12) { - strlcpy(source_p->info, parv[11], sizeof(source_p->info)); - strlcpy(source_p->sockhost, parv[7], sizeof(source_p->sockhost)); - strlcpy(source_p->id, parv[8], sizeof(source_p->id)); + rb_strlcpy(source_p->info, parv[11], sizeof(source_p->info)); + rb_strlcpy(source_p->sockhost, parv[7], sizeof(source_p->sockhost)); + rb_strlcpy(source_p->id, parv[8], sizeof(source_p->id)); add_to_id_hash(source_p->id, source_p); if (strcmp(parv[9], "*")) { - strlcpy(source_p->orighost, parv[9], sizeof(source_p->orighost)); + rb_strlcpy(source_p->orighost, parv[9], sizeof(source_p->orighost)); if (irccmp(source_p->host, source_p->orighost)) SetDynSpoof(source_p); } if (strcmp(parv[10], "*")) - strlcpy(source_p->user->suser, parv[10], sizeof(source_p->user->suser)); + rb_strlcpy(source_p->user->suser, parv[10], sizeof(source_p->user->suser)); } else if(parc == 10) { - strlcpy(source_p->info, parv[9], sizeof(source_p->info)); - strlcpy(source_p->sockhost, parv[7], sizeof(source_p->sockhost)); - strlcpy(source_p->id, parv[8], sizeof(source_p->id)); + rb_strlcpy(source_p->info, parv[9], sizeof(source_p->info)); + rb_strlcpy(source_p->sockhost, parv[7], sizeof(source_p->sockhost)); + rb_strlcpy(source_p->id, parv[8], sizeof(source_p->id)); add_to_id_hash(source_p->id, source_p); } else { - strlcpy(source_p->info, parv[8], sizeof(source_p->info)); + rb_strlcpy(source_p->info, parv[8], sizeof(source_p->info)); } /* remove any nd entries for this nick */ diff --git a/modules/core/m_part.c b/modules/core/m_part.c index d7536d7..a098b6e 100644 --- a/modules/core/m_part.c +++ b/modules/core/m_part.c @@ -71,7 +71,7 @@ m_part(struct Client *client_p, struct Client *source_p, int parc, const char *p reason[0] = '\0'; if(parc > 2) - strlcpy(reason, parv[2], sizeof(reason)); + rb_strlcpy(reason, parv[2], sizeof(reason)); name = strtoken(&p, s, ","); diff --git a/modules/core/m_server.c b/modules/core/m_server.c index 47c8816..0c90e62 100644 --- a/modules/core/m_server.c +++ b/modules/core/m_server.c @@ -79,7 +79,7 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char name = parv[1]; hop = atoi(parv[2]); - strlcpy(info, parv[3], sizeof(info)); + rb_strlcpy(info, parv[3], sizeof(info)); if (IsHandshake(client_p) && irccmp(client_p->name, name)) { @@ -230,7 +230,7 @@ mr_server(struct Client *client_p, struct Client *source_p, int parc, const char * C:line in client_p->name */ - strlcpy(client_p->name, name, sizeof(client_p->name)); + rb_strlcpy(client_p->name, name, sizeof(client_p->name)); set_server_gecos(client_p, info); client_p->hopcount = hop; server_estab(client_p); @@ -261,7 +261,7 @@ ms_server(struct Client *client_p, struct Client *source_p, int parc, const char name = parv[1]; hop = atoi(parv[2]); - strlcpy(info, parv[3], sizeof(info)); + rb_strlcpy(info, parv[3], sizeof(info)); if((target_p = find_server(NULL, name))) { @@ -421,7 +421,7 @@ ms_server(struct Client *client_p, struct Client *source_p, int parc, const char make_server(target_p); target_p->hopcount = hop; - strlcpy(target_p->name, name, sizeof(target_p->name)); + rb_strlcpy(target_p->name, name, sizeof(target_p->name)); set_server_gecos(target_p, info); @@ -569,7 +569,7 @@ ms_sid(struct Client *client_p, struct Client *source_p, int parc, const char *p target_p = make_client(client_p); make_server(target_p); - strlcpy(target_p->name, parv[1], sizeof(target_p->name)); + rb_strlcpy(target_p->name, parv[1], sizeof(target_p->name)); target_p->hopcount = atoi(parv[2]); strcpy(target_p->id, parv[3]); set_server_gecos(target_p, parv[4]); @@ -668,13 +668,13 @@ set_server_gecos(struct Client *client_p, const char *info) /* if there was a trailing space, s could point to \0, so check */ if(s && (*s != '\0')) { - strlcpy(client_p->info, s, sizeof(client_p->info)); + rb_strlcpy(client_p->info, s, sizeof(client_p->info)); return 1; } } } - strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info)); + rb_strlcpy(client_p->info, "(Unknown Location)", sizeof(client_p->info)); return 1; } diff --git a/modules/m_cap.c b/modules/m_cap.c index 5b69625..998d8f0 100644 --- a/modules/m_cap.c +++ b/modules/m_cap.c @@ -116,7 +116,7 @@ clicap_find(const char *data, int *negate, int *finished) if(data) { - strlcpy(buf, data, sizeof(buf)); + rb_strlcpy(buf, data, sizeof(buf)); p = buf; } @@ -322,7 +322,7 @@ cap_end(struct Client *source_p, const char *arg) if(source_p->name[0] && source_p->user) { char buf[USERLEN+1]; - strlcpy(buf, source_p->username, sizeof(buf)); + rb_strlcpy(buf, source_p->username, sizeof(buf)); register_local_user(source_p, source_p, buf); } } diff --git a/modules/m_challenge.c b/modules/m_challenge.c index f275324..0d2278e 100644 --- a/modules/m_challenge.c +++ b/modules/m_challenge.c @@ -229,7 +229,7 @@ m_challenge(struct Client *client_p, struct Client *source_p, int parc, const ch source_p->localClient->chal_time = rb_current_time(); for(;;) { - cnt = strlcpy(chal_line, chal, CHALLENGE_WIDTH); + cnt = rb_strlcpy(chal_line, chal, CHALLENGE_WIDTH); sendto_one(source_p, form_str(RPL_RSACHALLENGE2), me.name, source_p->name, chal_line); if(cnt > CHALLENGE_WIDTH) chal += CHALLENGE_WIDTH - 1; diff --git a/modules/m_chghost.c b/modules/m_chghost.c index f805cbb..92e2652 100644 --- a/modules/m_chghost.c +++ b/modules/m_chghost.c @@ -94,7 +94,7 @@ me_realhost(struct Client *client_p, struct Client *source_p, return 0; del_from_hostname_hash(source_p->orighost, source_p); - strlcpy(source_p->orighost, parv[1], sizeof source_p->orighost); + rb_strlcpy(source_p->orighost, parv[1], sizeof source_p->orighost); if (irccmp(source_p->host, source_p->orighost)) SetDynSpoof(source_p); else diff --git a/modules/m_dline.c b/modules/m_dline.c index 42c134e..4c2c633 100644 --- a/modules/m_dline.c +++ b/modules/m_dline.c @@ -103,7 +103,7 @@ mo_dline(struct Client *client_p, struct Client *source_p, } dlhost = parv[loc]; - strlcpy(cidr_form_host, dlhost, sizeof(cidr_form_host)); + rb_strlcpy(cidr_form_host, dlhost, sizeof(cidr_form_host)); if(!parse_netmask(dlhost, NULL, &bits)) { @@ -284,7 +284,7 @@ mo_undline(struct Client *client_p, struct Client *source_p, int parc, const cha return 0; } - strlcpy(buf, aconf->host, sizeof buf); + rb_strlcpy(buf, aconf->host, sizeof buf); if(remove_temp_dline(aconf)) { sendto_one(source_p, @@ -318,7 +318,7 @@ mo_undline(struct Client *client_p, struct Client *source_p, int parc, const cha while (fgets(buf, sizeof(buf), in)) { - strlcpy(buff, buf, sizeof(buff)); + rb_strlcpy(buff, buf, sizeof(buff)); if((p = strchr(buff, '\n')) != NULL) *p = '\0'; diff --git a/modules/m_etrace.c b/modules/m_etrace.c index b9bf4c1..92d2ca4 100644 --- a/modules/m_etrace.c +++ b/modules/m_etrace.c @@ -415,7 +415,7 @@ mo_masktrace(struct Client *client_p, struct Client *source_p, int parc, if (!ConfigFileEntry.operspy_dont_care_user_info) { char buf[512]; - strlcpy(buf, mask, sizeof(buf)); + rb_strlcpy(buf, mask, sizeof(buf)); if(!EmptyString(gecos)) { strlcat(buf, " ", sizeof(buf)); strlcat(buf, gecos, sizeof(buf)); diff --git a/modules/m_kline.c b/modules/m_kline.c index 04a936c..b14f0c3 100644 --- a/modules/m_kline.c +++ b/modules/m_kline.c @@ -554,11 +554,11 @@ find_user_host(struct Client *source_p, const char *userhost, char *luser, char { *(hostp++) = '\0'; /* short and squat */ if(*userhost) - strlcpy(luser, userhost, USERLEN + 1); /* here is my user */ + rb_strlcpy(luser, userhost, USERLEN + 1); /* here is my user */ else strcpy(luser, "*"); if(*hostp) - strlcpy(lhost, hostp, HOSTLEN + 1); /* here is my host */ + rb_strlcpy(lhost, hostp, HOSTLEN + 1); /* here is my host */ else strcpy(lhost, "*"); } @@ -572,7 +572,7 @@ find_user_host(struct Client *source_p, const char *userhost, char *luser, char luser[0] = '*'; /* no @ found, assume its *@somehost */ luser[1] = '\0'; - strlcpy(lhost, userhost, HOSTLEN + 1); + rb_strlcpy(lhost, userhost, HOSTLEN + 1); } return 1; diff --git a/modules/m_pong.c b/modules/m_pong.c index 82ce37c..7cf84d5 100644 --- a/modules/m_pong.c +++ b/modules/m_pong.c @@ -111,7 +111,7 @@ mr_pong(struct Client *client_p, struct Client *source_p, int parc, const char * if(source_p->localClient->random_ping == incoming_ping) { char buf[USERLEN + 1]; - strlcpy(buf, source_p->username, sizeof(buf)); + rb_strlcpy(buf, source_p->username, sizeof(buf)); source_p->flags |= FLAGS_PING_COOKIE; register_local_user(client_p, source_p, buf); } diff --git a/modules/m_resv.c b/modules/m_resv.c index 9d46750..900d430 100644 --- a/modules/m_resv.c +++ b/modules/m_resv.c @@ -577,7 +577,7 @@ remove_resv_from_file(struct Client *source_p, const char *name) break; } - strlcpy(buff, buf, sizeof(buff)); + rb_strlcpy(buff, buf, sizeof(buff)); if((p = strchr(buff, '\n')) != NULL) *p = '\0'; diff --git a/modules/m_sasl.c b/modules/m_sasl.c index d5f8714..41bf823 100644 --- a/modules/m_sasl.c +++ b/modules/m_sasl.c @@ -150,7 +150,7 @@ me_sasl(struct Client *client_p, struct Client *source_p, if(*target_p->preClient->sasl_agent && strncmp(parv[1], target_p->preClient->sasl_agent, IDLEN)) return 0; else if(!*target_p->preClient->sasl_agent) - strlcpy(target_p->preClient->sasl_agent, parv[1], IDLEN); + rb_strlcpy(target_p->preClient->sasl_agent, parv[1], IDLEN); if(*parv[3] == 'C') sendto_one(target_p, "AUTHENTICATE %s", parv[4]); diff --git a/modules/m_scan.c b/modules/m_scan.c index 37a0783..bee5e47 100644 --- a/modules/m_scan.c +++ b/modules/m_scan.c @@ -178,7 +178,7 @@ scan_umodes(struct Client *client_p, struct Client *source_p, int parc, { if (!ConfigFileEntry.operspy_dont_care_user_info) { - strlcpy(buf, "UMODES", sizeof buf); + rb_strlcpy(buf, "UMODES", sizeof buf); for (i = 2; i < parc; i++) { strlcat(buf, " ", sizeof buf); diff --git a/modules/m_services.c b/modules/m_services.c index af0e9c3..e11099d 100644 --- a/modules/m_services.c +++ b/modules/m_services.c @@ -106,7 +106,7 @@ me_su(struct Client *client_p, struct Client *source_p, if(EmptyString(parv[2])) target_p->user->suser[0] = '\0'; else - strlcpy(target_p->user->suser, parv[2], sizeof(target_p->user->suser)); + rb_strlcpy(target_p->user->suser, parv[2], sizeof(target_p->user->suser)); invalidate_bancache_user(target_p); @@ -120,7 +120,7 @@ me_login(struct Client *client_p, struct Client *source_p, if(!IsPerson(source_p)) return 0; - strlcpy(source_p->user->suser, parv[1], sizeof(source_p->user->suser)); + rb_strlcpy(source_p->user->suser, parv[1], sizeof(source_p->user->suser)); return 0; } diff --git a/modules/m_set.c b/modules/m_set.c index b518625..3d80d84 100644 --- a/modules/m_set.c +++ b/modules/m_set.c @@ -257,7 +257,7 @@ quote_operstring(struct Client *source_p, const char *arg) } else { - strlcpy(GlobalSetOptions.operstring, arg, + rb_strlcpy(GlobalSetOptions.operstring, arg, sizeof(GlobalSetOptions.operstring)); sendto_realops_snomask(SNO_GENERAL, L_ALL, @@ -276,7 +276,7 @@ quote_adminstring(struct Client *source_p, const char *arg) } else { - strlcpy(GlobalSetOptions.adminstring, arg, + rb_strlcpy(GlobalSetOptions.adminstring, arg, sizeof(GlobalSetOptions.adminstring)); sendto_realops_snomask(SNO_GENERAL, L_ALL, diff --git a/modules/m_signon.c b/modules/m_signon.c index 4d242da..592330a 100644 --- a/modules/m_signon.c +++ b/modules/m_signon.c @@ -163,41 +163,41 @@ me_svslogin(struct Client *client_p, struct Client *source_p, if(clean_nick(parv[2])) { - strlcpy(nick, parv[2], NICKLEN + 1); + rb_strlcpy(nick, parv[2], NICKLEN + 1); valid |= NICK_VALID; } else if(*target_p->name) - strlcpy(nick, target_p->name, NICKLEN + 1); + rb_strlcpy(nick, target_p->name, NICKLEN + 1); else strcpy(nick, "*"); if(clean_username(parv[3])) { - strlcpy(user, parv[3], USERLEN + 1); + rb_strlcpy(user, parv[3], USERLEN + 1); valid |= USER_VALID; } else - strlcpy(user, target_p->username, USERLEN + 1); + rb_strlcpy(user, target_p->username, USERLEN + 1); if(clean_host(parv[4])) { - strlcpy(host, parv[4], HOSTLEN + 1); + rb_strlcpy(host, parv[4], HOSTLEN + 1); valid |= HOST_VALID; } else - strlcpy(host, target_p->host, HOSTLEN + 1); + rb_strlcpy(host, target_p->host, HOSTLEN + 1); if(*parv[5] == '*') { if(target_p->user) - strlcpy(login, target_p->user->suser, NICKLEN + 1); + rb_strlcpy(login, target_p->user->suser, NICKLEN + 1); else login[0] = '\0'; } else if(!strcmp(parv[5], "0")) login[0] = '\0'; else - strlcpy(login, parv[5], NICKLEN + 1); + rb_strlcpy(login, parv[5], NICKLEN + 1); /* Login (mostly) follows nick rules. */ if(*login && !clean_nick(login)) @@ -251,7 +251,7 @@ me_svslogin(struct Client *client_p, struct Client *source_p, if(valid & HOST_VALID) strcpy(target_p->preClient->spoofhost, host); - strlcpy(user_p->suser, login, NICKLEN + 1); + rb_strlcpy(user_p->suser, login, NICKLEN + 1); } else { @@ -317,7 +317,7 @@ ms_signon(struct Client *client_p, struct Client *source_p, else if(*parv[5] != '*') { if (clean_nick(parv[5])) - strlcpy(login, parv[5], NICKLEN + 1); + rb_strlcpy(login, parv[5], NICKLEN + 1); else return 0; } diff --git a/modules/m_testline.c b/modules/m_testline.c index 51e5b77..58fc792 100644 --- a/modules/m_testline.c +++ b/modules/m_testline.c @@ -141,13 +141,13 @@ mo_testline(struct Client *client_p, struct Client *source_p, int parc, const ch if (username != NULL) { - strlcpy(user_trunc, username, sizeof user_trunc); - strlcpy(notildeuser_trunc, *username == '~' ? username + 1 : username, sizeof notildeuser_trunc); + rb_strlcpy(user_trunc, username, sizeof user_trunc); + rb_strlcpy(notildeuser_trunc, *username == '~' ? username + 1 : username, sizeof notildeuser_trunc); } else { - strlcpy(user_trunc, "dummy", sizeof user_trunc); - strlcpy(notildeuser_trunc, "dummy", sizeof notildeuser_trunc); + rb_strlcpy(user_trunc, "dummy", sizeof user_trunc); + rb_strlcpy(notildeuser_trunc, "dummy", sizeof notildeuser_trunc); } /* now look for a matching I/K/G */ if((aconf = find_address_conf(host, NULL, user_trunc, notildeuser_trunc, diff --git a/modules/m_user.c b/modules/m_user.c index aa12a6c..c2f61c3 100644 --- a/modules/m_user.c +++ b/modules/m_user.c @@ -97,14 +97,14 @@ do_local_user(struct Client *client_p, struct Client *source_p, source_p->flags |= FLAGS_SENTUSER; } - strlcpy(source_p->info, realname, sizeof(source_p->info)); + rb_strlcpy(source_p->info, realname, sizeof(source_p->info)); if(!IsGotId(source_p)) { /* This is in this location for a reason..If there is no identd * and ping cookies are enabled..we need to have a copy of this */ - strlcpy(source_p->username, username, sizeof(source_p->username)); + rb_strlcpy(source_p->username, username, sizeof(source_p->username)); } if(source_p->name[0]) diff --git a/modules/m_xline.c b/modules/m_xline.c index fb615ad..954cee2 100644 --- a/modules/m_xline.c +++ b/modules/m_xline.c @@ -622,7 +622,7 @@ remove_xline_from_file(struct Client *source_p, const char *huntgecos) break; } - strlcpy(buff, buf, sizeof(buff)); + rb_strlcpy(buff, buf, sizeof(buff)); if((p = strchr(buff, '\n')) != NULL) *p = '\0'; diff --git a/src/blacklist.c b/src/blacklist.c index 50de9ad..572cadd 100644 --- a/src/blacklist.c +++ b/src/blacklist.c @@ -106,7 +106,7 @@ static void blacklist_dns_callback(void *vptr, struct DNSReply *reply) if (rb_dlink_list_length(&blcptr->client_p->preClient->dnsbl_queries) == 0 && blcptr->client_p->flags & FLAGS_SENTUSER && !EmptyString(blcptr->client_p->name)) { char buf[USERLEN + 1]; - strlcpy(buf, blcptr->client_p->username, sizeof buf); + rb_strlcpy(buf, blcptr->client_p->username, sizeof buf); register_local_user(blcptr->client_p, blcptr->client_p, buf); } @@ -154,8 +154,8 @@ struct Blacklist *new_blacklist(char *name, char *reject_reason) } else blptr->status &= ~CONF_ILLEGAL; - strlcpy(blptr->host, name, HOSTLEN); - strlcpy(blptr->reject_reason, reject_reason, IRCD_BUFSIZE); + rb_strlcpy(blptr->host, name, HOSTLEN); + rb_strlcpy(blptr->reject_reason, reject_reason, IRCD_BUFSIZE); blptr->lastwarning = 0; return blptr; diff --git a/src/channel.c b/src/channel.c index d1acd20..1fb8863 100644 --- a/src/channel.c +++ b/src/channel.c @@ -1068,8 +1068,8 @@ set_channel_topic(struct Channel *chptr, const char *topic, const char *topic_in { if(chptr->topic == NULL) allocate_topic(chptr); - strlcpy(chptr->topic, topic, TOPICLEN + 1); - strlcpy(chptr->topic_info, topic_info, USERHOST_REPLYLEN); + rb_strlcpy(chptr->topic, topic, TOPICLEN + 1); + rb_strlcpy(chptr->topic_info, topic_info, USERHOST_REPLYLEN); chptr->topic_time = topicts; } else @@ -1160,7 +1160,7 @@ channel_modes(struct Channel *chptr, struct Client *client_p) *mbuf = '\0'; - strlcpy(final, buf1, sizeof final); + rb_strlcpy(final, buf1, sizeof final); strlcat(final, buf2, sizeof final); return final; } diff --git a/src/chmode.c b/src/chmode.c index 81c4202..9fca471 100644 --- a/src/chmode.c +++ b/src/chmode.c @@ -127,7 +127,7 @@ add_id(struct Client *source_p, struct Channel *chptr, const char *banid, if(IsPerson(source_p)) rb_sprintf(who, "%s!%s@%s", source_p->name, source_p->username, source_p->host); else - strlcpy(who, source_p->name, sizeof(who)); + rb_strlcpy(who, source_p->name, sizeof(who)); actualBan = allocate_ban(realban, who); actualBan->when = rb_current_time(); @@ -1036,7 +1036,7 @@ chm_forward(struct Client *source_p, struct Channel *chptr, } } - strlcpy(chptr->mode.forward, forward, sizeof(chptr->mode.forward)); + rb_strlcpy(chptr->mode.forward, forward, sizeof(chptr->mode.forward)); mode_changes[mode_count].letter = c; mode_changes[mode_count].dir = MODE_ADD; @@ -1096,7 +1096,7 @@ chm_key(struct Client *source_p, struct Channel *chptr, return; s_assert(key[0] != ' '); - strlcpy(chptr->mode.key, key, sizeof(chptr->mode.key)); + rb_strlcpy(chptr->mode.key, key, sizeof(chptr->mode.key)); mode_changes[mode_count].letter = c; mode_changes[mode_count].dir = MODE_ADD; diff --git a/src/client.c b/src/client.c index 96d7372..497a7b6 100644 --- a/src/client.c +++ b/src/client.c @@ -1231,7 +1231,7 @@ dead_link(struct Client *client_p) abt = (struct abort_client *) rb_malloc(sizeof(struct abort_client)); if(client_p->flags & FLAGS_SENDQEX) - strlcpy(abt->notice, "Max SendQ exceeded", sizeof(abt->notice)); + rb_strlcpy(abt->notice, "Max SendQ exceeded", sizeof(abt->notice)); else rb_snprintf(abt->notice, sizeof(abt->notice), "Write error: %s", strerror(errno)); @@ -2053,7 +2053,7 @@ error_exit_client(struct Client *client_p, int error) } if(error == 0) - strlcpy(errmsg, "Remote host closed the connection", sizeof(errmsg)); + rb_strlcpy(errmsg, "Remote host closed the connection", sizeof(errmsg)); else rb_snprintf(errmsg, sizeof(errmsg), "Read error: %s", strerror(current_error)); diff --git a/src/irc_string.c b/src/irc_string.c index 62cdc7e..4728deb 100644 --- a/src/irc_string.c +++ b/src/irc_string.c @@ -787,36 +787,6 @@ strlcat(char *dst, const char *src, size_t siz) } #endif -#ifndef HAVE_STRLCPY -size_t -strlcpy(char *dst, const char *src, size_t siz) -{ - char *d = dst; - const char *s = src; - size_t n = siz; - /* Copy as many bytes as will fit */ - if(n != 0 && --n != 0) - { - do - { - if((*d++ = *s++) == 0) - break; - } - while(--n != 0); - } - /* Not enough room in dst, add NUL and traverse rest of src */ - if(n == 0) - { - if(siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while(*s++) - ; - } - - return (s - src - 1); /* count does not include NUL */ -} -#endif - char * strip_colour(char *string) { diff --git a/src/ircd.c b/src/ircd.c index b46ee03..689d2da 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -388,10 +388,10 @@ initialize_global_set_options(void) GlobalSetOptions.ident_timeout = IDENT_TIMEOUT; - strlcpy(GlobalSetOptions.operstring, + rb_strlcpy(GlobalSetOptions.operstring, ConfigFileEntry.default_operstring, sizeof(GlobalSetOptions.operstring)); - strlcpy(GlobalSetOptions.adminstring, + rb_strlcpy(GlobalSetOptions.adminstring, ConfigFileEntry.default_adminstring, sizeof(GlobalSetOptions.adminstring)); @@ -696,7 +696,7 @@ main(int argc, char *argv[]) ierror("no server name specified in serverinfo block."); return -1; } - strlcpy(me.name, ServerInfo.name, sizeof(me.name)); + rb_strlcpy(me.name, ServerInfo.name, sizeof(me.name)); if(ServerInfo.sid[0] == '\0') { @@ -712,7 +712,7 @@ main(int argc, char *argv[]) ierror("no server description specified in serverinfo block."); return -3; } - strlcpy(me.info, ServerInfo.description, sizeof(me.info)); + rb_strlcpy(me.info, ServerInfo.description, sizeof(me.info)); if(ServerInfo.ssl_cert != NULL && ServerInfo.ssl_private_key != NULL) { diff --git a/src/listener.c b/src/listener.c index 4147bfa..153e1eb 100644 --- a/src/listener.c +++ b/src/listener.c @@ -457,7 +457,7 @@ add_connection(struct Listener *listener, rb_fde_t *F, struct sockaddr *sai, voi sizeof(new_client->sockhost)); - strlcpy(new_client->host, new_client->sockhost, sizeof(new_client->host)); + rb_strlcpy(new_client->host, new_client->sockhost, sizeof(new_client->host)); new_client->localClient->F = F; add_to_cli_fd_hash(new_client); diff --git a/src/res.c b/src/res.c index 8d0d94f..aff4bd8 100644 --- a/src/res.c +++ b/src/res.c @@ -407,7 +407,7 @@ static void do_query_name(struct DNSQuery *query, const char *name, struct resli { char host_name[HOSTLEN + 1]; - strlcpy(host_name, name, HOSTLEN + 1); + rb_strlcpy(host_name, name, HOSTLEN + 1); add_local_domain(host_name, HOSTLEN); if (request == NULL) @@ -418,7 +418,7 @@ static void do_query_name(struct DNSQuery *query, const char *name, struct resli request->state = REQ_A; } - strlcpy(request->queryname, host_name, sizeof(request->queryname)); + rb_strlcpy(request->queryname, host_name, sizeof(request->queryname)); request->type = type; query_name(request); } @@ -681,7 +681,7 @@ static int proc_answer(struct reslist *request, HEADER * header, char *buf, char else if (n == 0) return (0); /* no more answers left */ - strlcpy(request->name, hostbuf, HOSTLEN + 1); + rb_strlcpy(request->name, hostbuf, HOSTLEN + 1); return (1); break; @@ -866,7 +866,7 @@ void report_dns_servers(struct Client *source_p) { if (!inetntop_sock((struct sockaddr *)&(irc_nsaddr_list[i]), ipaddr, sizeof ipaddr)) - strlcpy(ipaddr, "?", sizeof ipaddr); + rb_strlcpy(ipaddr, "?", sizeof ipaddr); sendto_one_numeric(source_p, RPL_STATSDEBUG, "A %s", ipaddr); } diff --git a/src/reslib.c b/src/reslib.c index 4d2236e..5a8e4f6 100644 --- a/src/reslib.c +++ b/src/reslib.c @@ -209,7 +209,7 @@ parse_resvconf(void) *p = '\0'; /* take the first word */ if (irccmp(opt, "domain") == 0) - strlcpy(irc_domain, arg, sizeof(irc_domain)); + rb_strlcpy(irc_domain, arg, sizeof(irc_domain)); else if (irccmp(opt, "nameserver") == 0) add_nameserver(arg); } diff --git a/src/s_auth.c b/src/s_auth.c index 21236b4..6c27d21 100644 --- a/src/s_auth.c +++ b/src/s_auth.c @@ -222,7 +222,7 @@ auth_dns_callback(void *vptr, struct DNSReply *reply) if(good && strlen(reply->h_name) <= HOSTLEN) { - strlcpy(auth->client->host, reply->h_name, sizeof(auth->client->host)); + rb_strlcpy(auth->client->host, reply->h_name, sizeof(auth->client->host)); sendheader(auth->client, REPORT_FIN_DNS); } else if (strlen(reply->h_name) > HOSTLEN) diff --git a/src/s_conf.c b/src/s_conf.c index 98bd9b6..632d481 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -313,7 +313,7 @@ verify_access(struct Client *client_p, const char *username) } else { - strlcpy(non_ident, "~", sizeof(non_ident)); + rb_strlcpy(non_ident, "~", sizeof(non_ident)); strlcat(non_ident, username, sizeof(non_ident)); aconf = find_address_conf(client_p->host, client_p->sockhost, non_ident, client_p->username, @@ -356,14 +356,14 @@ verify_access(struct Client *client_p, const char *username) char *host = p+1; *p = '\0'; - strlcpy(client_p->username, aconf->name, + rb_strlcpy(client_p->username, aconf->name, sizeof(client_p->username)); - strlcpy(client_p->host, host, + rb_strlcpy(client_p->host, host, sizeof(client_p->host)); *p = '@'; } else - strlcpy(client_p->host, aconf->name, sizeof(client_p->host)); + rb_strlcpy(client_p->host, aconf->name, sizeof(client_p->host)); } return (attach_iline(client_p, aconf)); } @@ -616,9 +616,9 @@ rehash(int sig) read_conf_files(NO); if(ServerInfo.description != NULL) - strlcpy(me.info, ServerInfo.description, sizeof(me.info)); + rb_strlcpy(me.info, ServerInfo.description, sizeof(me.info)); else - strlcpy(me.info, "unknown", sizeof(me.info)); + rb_strlcpy(me.info, "unknown", sizeof(me.info)); open_logfiles(); return (0); @@ -1162,7 +1162,7 @@ read_conf_files(int cold) - Gozem 2002-07-21 */ - strlcpy(conffilebuf, filename, sizeof(conffilebuf)); + rb_strlcpy(conffilebuf, filename, sizeof(conffilebuf)); if((conf_fbfile_in = fopen(filename, "r")) == NULL) { diff --git a/src/s_newconf.c b/src/s_newconf.c index 1bf84ad..6da826c 100644 --- a/src/s_newconf.c +++ b/src/s_newconf.c @@ -299,7 +299,7 @@ find_oper_conf(const char *username, const char *host, const char *locip, const if(irccmp(oper_p->name, name) || !match(oper_p->username, username)) continue; - strlcpy(addr, oper_p->host, sizeof(addr)); + rb_strlcpy(addr, oper_p->host, sizeof(addr)); if(parse_netmask(addr, (struct sockaddr *)&ip, &bits) != HM_HOST) { @@ -755,7 +755,7 @@ add_nd_entry(const char *name) nd = rb_bh_alloc(nd_heap); - strlcpy(nd->name, name, sizeof(nd->name)); + rb_strlcpy(nd->name, name, sizeof(nd->name)); nd->expire = rb_current_time() + ConfigFileEntry.nick_delay; /* this list is ordered */ diff --git a/src/s_serv.c b/src/s_serv.c index 9af385e..32a3b8e 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -1296,9 +1296,9 @@ serv_connect(struct server_conf *server_p, struct Client *by) * The sockhost may be a hostname, this will be corrected later * -- jilles */ - strlcpy(client_p->name, server_p->name, sizeof(client_p->name)); - strlcpy(client_p->host, server_p->host, sizeof(client_p->host)); - strlcpy(client_p->sockhost, server_p->host, sizeof(client_p->sockhost)); + rb_strlcpy(client_p->name, server_p->name, sizeof(client_p->name)); + rb_strlcpy(client_p->host, server_p->host, sizeof(client_p->host)); + rb_strlcpy(client_p->sockhost, server_p->host, sizeof(client_p->sockhost)); client_p->localClient->F = F; add_to_cli_fd_hash(client_p); diff --git a/src/s_user.c b/src/s_user.c index 2d189ce..57cf9ec 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -293,7 +293,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char char note[NICKLEN + 10]; del_from_client_hash(source_p->name, source_p); - strlcpy(source_p->name, source_p->preClient->spoofnick, NICKLEN + 1); + rb_strlcpy(source_p->name, source_p->preClient->spoofnick, NICKLEN + 1); add_to_client_hash(source_p->name, source_p); rb_snprintf(note, NICKLEN + 10, "Nick: %s", source_p->name); @@ -304,7 +304,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char { sendto_one_notice(source_p, ":*** Notice -- You have an illegal character in your hostname"); - strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host)); + rb_strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host)); } @@ -470,14 +470,14 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char /* end of valid user name check */ /* Store original hostname -- jilles */ - strlcpy(source_p->orighost, source_p->host, HOSTLEN + 1); + rb_strlcpy(source_p->orighost, source_p->host, HOSTLEN + 1); /* Spoof user@host */ if(*source_p->preClient->spoofuser) - strlcpy(source_p->username, source_p->preClient->spoofuser, USERLEN + 1); + rb_strlcpy(source_p->username, source_p->preClient->spoofuser, USERLEN + 1); if(*source_p->preClient->spoofhost) { - strlcpy(source_p->host, source_p->preClient->spoofhost, HOSTLEN + 1); + rb_strlcpy(source_p->host, source_p->preClient->spoofhost, HOSTLEN + 1); if (irccmp(source_p->host, source_p->orighost)) SetDynSpoof(source_p); } @@ -1437,14 +1437,14 @@ change_nick_user_host(struct Client *target_p, const char *nick, const char *use target_p->host, nick); } - strlcpy(target_p->username, user, sizeof target_p->username); - strlcpy(target_p->host, host, sizeof target_p->host); + rb_strlcpy(target_p->username, user, sizeof target_p->username); + rb_strlcpy(target_p->host, host, sizeof target_p->host); if (changed) add_history(target_p, 1); del_from_client_hash(target_p->name, target_p); - strlcpy(target_p->name, nick, NICKLEN); + rb_strlcpy(target_p->name, nick, NICKLEN); add_to_client_hash(target_p->name, target_p); if(changed) diff --git a/src/scache.c b/src/scache.c index 920ebad..1ec035d 100644 --- a/src/scache.c +++ b/src/scache.c @@ -102,7 +102,7 @@ find_or_add(const char *name) ptr = (struct scache_entry *) rb_malloc(sizeof(struct scache_entry)); s_assert(0 != ptr); - strlcpy(ptr->name, name, sizeof(ptr->name)); + rb_strlcpy(ptr->name, name, sizeof(ptr->name)); ptr->info[0] = '\0'; ptr->flags = 0; ptr->known_since = rb_current_time(); @@ -120,7 +120,7 @@ scache_connect(const char *name, const char *info, int hidden) struct scache_entry *ptr; ptr = find_or_add(name); - strlcpy(ptr->info, info, sizeof(ptr->info)); + rb_strlcpy(ptr->info, info, sizeof(ptr->info)); ptr->flags |= SC_ONLINE; if (hidden) ptr->flags |= SC_HIDDEN; diff --git a/src/substitution.c b/src/substitution.c index 032d42a..81e8b68 100644 --- a/src/substitution.c +++ b/src/substitution.c @@ -136,7 +136,7 @@ char *substitution_parse(const char *fmt, rb_dlink_list *varlist) if (!strcasecmp(varname, val->name)) { - strlcpy(bptr, val->value, BUFSIZE - (bptr - buf)); + rb_strlcpy(bptr, val->value, BUFSIZE - (bptr - buf)); bptr += strlen(val->value); break; } diff --git a/src/whowas.c b/src/whowas.c index 4e31df7..36de913 100644 --- a/src/whowas.c +++ b/src/whowas.c @@ -77,7 +77,7 @@ void add_history(struct Client *client_p, int online) * NOTE: strcpy ok here, the sizes in the client struct MUST * match the sizes in the whowas struct */ - strlcpy(who->name, client_p->name, sizeof(who->name)); + rb_strlcpy(who->name, client_p->name, sizeof(who->name)); strcpy(who->username, client_p->username); strcpy(who->hostname, client_p->host); strcpy(who->realname, client_p->info);