]> jfr.im git - irc/rqf/shadowircd.git/commitdiff
libratbox: Clean up uses of strcpy().
authorWilliam Pitcock <redacted>
Tue, 23 Nov 2010 14:52:18 +0000 (08:52 -0600)
committerWilliam Pitcock <redacted>
Tue, 23 Nov 2010 14:52:18 +0000 (08:52 -0600)
libratbox/src/commio.c
libratbox/src/crypt.c
libratbox/src/patricia.c
libratbox/src/ratbox_lib.c

index 17066e64d0232a9473a97ba1516fb3099183a6a0..56432a50615c03c65da2579e0f6223138d06a23a 100644 (file)
@@ -1197,7 +1197,7 @@ inet_ntop4(const unsigned char *src, char *dst, unsigned int size)
 {
        if(size < 16)
                return NULL;
-       return strcpy(dst, inetntoa((const char *)src));
+       return rb_strlcpy(dst, inetntoa((const char *)src), size);
 }
 
 /* const char *
@@ -1309,7 +1309,7 @@ inet_ntop6(const unsigned char *src, char *dst, unsigned int size)
        {
                return (NULL);
        }
-       return strcpy(dst, tmp);
+       return rb_strlcpy(dst, tmp, size);
 }
 #endif
 
index c6d7135d3a3becbf89a5628ce977dcc05c8fe40c..b4ef99ff3e75f54542a9a2107a9b9a3c835ec32b 100644 (file)
@@ -1450,9 +1450,9 @@ __md5_crypt(const char *pw, const char *salt)
        }
 
        /* Now make the output string */
-       strcpy(passwd, __md5__magic);
+       rb_strlcpy(passwd, __md5__magic, sizeof(passwd));
        strncat(passwd, sp, sl);
-       strcat(passwd, "$");
+       rb_strlcat(passwd, "$", sizeof(passwd));
 
        __md5_Final(final, &ctx);
 
index 7cb23461971e3c8f62a3ccd6365738868ddb46f8..438763eb53fe1f1f2c4d93c6085550b781ab5616 100644 (file)
@@ -71,7 +71,7 @@ prefix_toa2x(rb_prefix_t *prefix, char *buf, int buf_len, int with_len)
        static char tmp[6];
        if(prefix == NULL)
        {
-               strcpy(buf, "(NULL)");
+               rb_strlcpy(buf, "(NULL)", buf_len);
                return (buf);
        }
        inet_ntop(prefix->family, &prefix->add.sin, buf, buf_len);
index 3873d78d9cde25c16d7ce4265e7f0a5d72141e70..028a91f73b8d12d60976f154473df939a2ca11b2 100644 (file)
@@ -69,12 +69,6 @@ rb_ctime(const time_t t, char *buf, size_t len)
 #else
        tp = gmtime(&t);
 #endif
-       if(rb_unlikely(tp == NULL))
-       {
-               strcpy(buf, "");
-               return (buf);
-       }
-
        if(buf == NULL)
        {
                p = timex;
@@ -86,6 +80,12 @@ rb_ctime(const time_t t, char *buf, size_t len)
                tlen = len;
        }
 
+       if(rb_unlikely(tp == NULL))
+       {
+               rb_strlcpy(p, "", tlen);
+               return (p);
+       }
+
        rb_snprintf(p, tlen, "%s %s %d %02u:%02u:%02u %d",
                    s_weekdays[tp->tm_wday], s_month[tp->tm_mon],
                    tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec, tp->tm_year + 1900);