]> jfr.im git - solanum.git/commitdiff
strcpy: mass-migrate to strlcpy where appropriate
authorAaron Jones <redacted>
Sun, 15 May 2016 03:57:16 +0000 (03:57 +0000)
committerAaron Jones <redacted>
Sun, 15 May 2016 03:57:16 +0000 (03:57 +0000)
13 files changed:
ircd/client.c
ircd/ircd.c
ircd/match.c
ircd/newconf.c
ircd/s_serv.c
ircd/s_user.c
ircd/sslproc.c
modules/core/m_join.c
modules/core/m_nick.c
modules/core/m_server.c
modules/m_pass.c
modules/m_sasl.c
modules/m_signon.c

index d33aa13e3da0d451431dcc7433dfcb18cc6eb34f..9ec5c6cc759414fa464462a10985daefab82e1a7 100644 (file)
@@ -247,7 +247,7 @@ make_client(struct Client *from)
        }
 
        SetUnknown(client_p);
-       strcpy(client_p->username, "unknown");
+       rb_strlcpy(client_p->username, "unknown", sizeof(client_p->username));
 
        return client_p;
 }
index 998e2c879a10eccc3787818e844af8e3d9e7c03d..9df6a75960ee7ed6ec8dccd7685733878972dc78 100644 (file)
@@ -815,7 +815,7 @@ charybdis_main(int argc, char * const argv[])
                ierror("no server sid specified in serverinfo block.");
                return -2;
        }
-       strcpy(me.id, ServerInfo.sid);
+       rb_strlcpy(me.id, ServerInfo.sid, sizeof(me.id));
        init_uid();
 
        /* serverinfo{} description must exist.  If not, error out. */
index 66ffe2364db64be42c3b691d9091346b7b6a246d..165baeabc083c59d90b0033e7127bf8b76d2591f 100644 (file)
@@ -358,8 +358,8 @@ int match_ips(const char *s1, const char *s2)
        void *ipptr, *maskptr;
        int cidrlen, aftype;
 
-       strcpy(mask, s1);
-       strcpy(address, s2);
+       rb_strlcpy(mask, s1, sizeof(mask));
+       rb_strlcpy(address, s2, sizeof(address));
 
        len = strrchr(mask, '/');
        if (len == NULL)
@@ -422,8 +422,8 @@ int match_cidr(const char *s1, const char *s2)
        void *ipptr, *maskptr;
        int cidrlen, aftype;
 
-       strcpy(mask, s1);
-       strcpy(address, s2);
+       rb_strlcpy(mask, s1, sizeof(mask));
+       rb_strlcpy(address, s2, sizeof(address));
 
        ipmask = strrchr(mask, '@');
        if (ipmask == NULL)
index 4f245063bad078c74dfeedadc4dc4cb25e53bf3b..72e6060a0609f1e3f1d5332debe2f794f4605e50 100644 (file)
@@ -225,7 +225,7 @@ conf_set_serverinfo_sid(void *data)
                        return;
                }
 
-               strcpy(ServerInfo.sid, sid);
+               rb_strlcpy(ServerInfo.sid, sid, sizeof(ServerInfo.sid));
        }
 }
 
index 7b5d15cb773c2ec9f23119e5d29800f119f52cf2..5c3fa62a01eedf2b347efbfed809896edf2bb091 100644 (file)
@@ -1132,7 +1132,7 @@ serv_connect(struct server_conf *server_p, struct Client *by)
         */
        make_server(client_p);
        if(by && IsClient(by))
-               strcpy(client_p->serv->by, by->name);
+               rb_strlcpy(client_p->serv->by, by->name, sizeof(client_p->serv->by));
        else
                strcpy(client_p->serv->by, "AutoConn.");
 
index 7c668b89bf94d995559acf9ba7cbd9f81d760cd2..b18df182ce3b3200c3c1aac8333c4569650ec941 100644 (file)
@@ -621,7 +621,7 @@ register_local_user(struct Client *client_p, struct Client *source_p)
         */
        if(!*source_p->id)
        {
-               strcpy(source_p->id, generate_uid());
+               rb_strlcpy(source_p->id, generate_uid(), sizeof(source_p->id));
                add_to_id_hash(source_p->id, source_p);
        }
 
index 941fd9c1156aae257365c1209d2860cdbe6835d6..b8d551bbe56f7c4b9b6924be80271042e5a7e09c 100644 (file)
@@ -524,7 +524,7 @@ ssl_process_certfp(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
 
        rb_free(client_p->certfp);
        certfp_string = rb_malloc(method_len + len * 2 + 1);
-       strcpy(certfp_string, method_string);
+       rb_strlcpy(certfp_string, method_string, method_len + len * 2 + 1);
        for(uint32_t i = 0; i < len; i++)
                snprintf(certfp_string + method_len + 2 * i, 3, "%02x",
                                certfp[i]);
index 5ed6cb29361cf658aeaca828e0b8df8045c2ce41..f74d7dd5b69b92392ea4d7d66884258cd6aaa9d8 100644 (file)
@@ -179,7 +179,7 @@ m_join(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
                /* join 0 parts all channels */
                if(*name == '0' && (name[1] == ',' || name[1] == '\0') && name == chanlist)
                {
-                       (void) strcpy(jbuf, "0");
+                       rb_strlcpy(jbuf, "0", sizeof(jbuf));
                        continue;
                }
 
@@ -687,7 +687,7 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
                if(oldmode->limit > mode.limit)
                        mode.limit = oldmode->limit;
                if(strcmp(mode.key, oldmode->key) < 0)
-                       strcpy(mode.key, oldmode->key);
+                       rb_strlcpy(mode.key, oldmode->key, sizeof(mode.key));
                if(oldmode->join_num > mode.join_num ||
                                (oldmode->join_num == mode.join_num &&
                                 oldmode->join_time > mode.join_time))
@@ -696,7 +696,7 @@ ms_sjoin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source
                        mode.join_time = oldmode->join_time;
                }
                if(irccmp(mode.forward, oldmode->forward) < 0)
-                       strcpy(mode.forward, oldmode->forward);
+                       rb_strlcpy(mode.forward, oldmode->forward, sizeof(mode.forward));
        }
        else
        {
index 7930ddea95d81ae80b60690b7d8b50727f8ade76..81f916ec32c44ad4e2a0188393824d6020778b4b 100644 (file)
@@ -155,7 +155,7 @@ mr_nick(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
        if((target_p = find_named_client(nick)) == NULL)
                set_initial_nick(client_p, source_p, nick);
        else if(source_p == target_p)
-               strcpy(source_p->name, nick);
+               rb_strlcpy(source_p->name, nick, sizeof(source_p->name));
        else
                sendto_one(source_p, form_str(ERR_NICKNAMEINUSE), me.name, "*", nick);
 }
@@ -593,7 +593,7 @@ set_initial_nick(struct Client *client_p, struct Client *source_p, char *nick)
        if(source_p->name[0])
                del_from_client_hash(source_p->name, source_p);
 
-       strcpy(source_p->name, nick);
+       rb_strlcpy(source_p->name, nick, sizeof(source_p->name));
        add_to_client_hash(nick, source_p);
 
        snprintf(note, sizeof(note), "Nick: %s", nick);
@@ -680,7 +680,7 @@ change_local_nick(struct Client *client_p, struct Client *source_p,
 
        /* Finally, add to hash */
        del_from_client_hash(source_p->name, source_p);
-       strcpy(source_p->name, nick);
+       rb_strlcpy(source_p->name, nick, sizeof(source_p->name));
        add_to_client_hash(nick, source_p);
 
        if(!samenick)
@@ -743,7 +743,7 @@ change_remote_nick(struct Client *client_p, struct Client *source_p,
        if((nd = rb_dictionary_retrieve(nd_dict, nick)))
                free_nd_entry(nd);
 
-       strcpy(source_p->name, nick);
+       rb_strlcpy(source_p->name, nick, sizeof(source_p->name));
        add_to_client_hash(nick, source_p);
 
        if(!samenick)
@@ -1023,7 +1023,7 @@ register_client(struct Client *client_p, struct Client *server,
        source_p->hopcount = atoi(parv[2]);
        source_p->tsinfo = newts;
 
-       strcpy(source_p->name, nick);
+       rb_strlcpy(source_p->name, nick, sizeof(source_p->name));
        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));
index 213d7f511f433a271c0d784340624a51d3e912d9..1ceaca9f821de10ee7ebb33da68722463f6278d0 100644 (file)
@@ -636,7 +636,7 @@ ms_sid(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p
 
        rb_strlcpy(target_p->name, parv[1], sizeof(target_p->name));
        target_p->hopcount = atoi(parv[2]);
-       strcpy(target_p->id, parv[3]);
+       rb_strlcpy(target_p->id, parv[3], sizeof(target_p->id));
        set_server_gecos(target_p, parv[4]);
 
        target_p->servptr = source_p;
index bf60e2e158a8cbaf21fe3bda29f1489b0072d418..36398055e3a0a1a903d944e05f75197707f0cf06 100644 (file)
@@ -104,7 +104,7 @@ mr_pass(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_
                           EmptyString(client_p->id))
                        {
                                client_p->localClient->caps |= CAP_TS6;
-                               strcpy(client_p->id, parv[4]);
+                               rb_strlcpy(client_p->id, parv[4], sizeof(client_p->id));
                        }
                }
        }
index 470832cb85d5c4f72b99797a98c5dee224ee059d..ee2010179ffcfcf647124326c85a9e2478ea9ef9 100644 (file)
@@ -165,7 +165,7 @@ m_authenticate(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *
        if(!*source_p->id)
        {
                /* Allocate a UID. */
-               strcpy(source_p->id, generate_uid());
+               rb_strlcpy(source_p->id, generate_uid(), sizeof(source_p->id));
                add_to_id_hash(source_p->id, source_p);
        }
 
index 9175c35797a1dfb4e9de01cf9032f8fdee145c12..6aeecc4714a10918897768bb6e808a732307632b 100644 (file)
@@ -221,13 +221,13 @@ me_svslogin(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou
                struct User *user_p = make_user(target_p);
 
                if(valid & NICK_VALID)
-                       strcpy(target_p->preClient->spoofnick, nick);
+                       rb_strlcpy(target_p->preClient->spoofnick, nick, sizeof(target_p->preClient->spoofnick));
 
                if(valid & USER_VALID)
-                       strcpy(target_p->preClient->spoofuser, user);
+                       rb_strlcpy(target_p->preClient->spoofuser, user, sizeof(target_p->preClient->spoofuser));
 
                if(valid & HOST_VALID)
-                       strcpy(target_p->preClient->spoofhost, host);
+                       rb_strlcpy(target_p->preClient->spoofhost, host, sizeof(target_p->preClient->spoofhost));
 
                rb_strlcpy(user_p->suser, login, NICKLEN + 1);
        }
@@ -410,7 +410,7 @@ send_signon(struct Client *client_p, struct Client *target_p,
                        use_id(target_p), nick, user, host,
                        (long) target_p->tsinfo, *login ? login : "0");
 
-       strcpy(target_p->user->suser, login);
+       rb_strlcpy(target_p->user->suser, login, sizeof(target_p->user->suser));
 
        change_nick_user_host(target_p, nick, user, host, newts, "Signing %s (%s)", *login ?  "in" : "out", nick);
 }