libratbox: Clean up uses of strcpy().

This commit is contained in:
William Pitcock 2010-11-23 08:52:18 -06:00
parent eac04554fd
commit 56c1612ff3
4 changed files with 11 additions and 11 deletions

View file

@ -1198,7 +1198,7 @@ inet_ntop4(const unsigned char *src, char *dst, unsigned int size)
{ {
if(size < 16) if(size < 16)
return NULL; return NULL;
return strcpy(dst, inetntoa((const char *)src)); return rb_strlcpy(dst, inetntoa((const char *)src), size);
} }
/* const char * /* const char *
@ -1310,7 +1310,7 @@ inet_ntop6(const unsigned char *src, char *dst, unsigned int size)
{ {
return (NULL); return (NULL);
} }
return strcpy(dst, tmp); return rb_strlcpy(dst, tmp, size);
} }
#endif #endif

View file

@ -1450,9 +1450,9 @@ __md5_crypt(const char *pw, const char *salt)
} }
/* Now make the output string */ /* Now make the output string */
strcpy(passwd, __md5__magic); rb_strlcpy(passwd, __md5__magic, sizeof(passwd));
strncat(passwd, sp, sl); strncat(passwd, sp, sl);
strcat(passwd, "$"); rb_strlcat(passwd, "$", sizeof(passwd));
__md5_Final(final, &ctx); __md5_Final(final, &ctx);

View file

@ -72,7 +72,7 @@ prefix_toa2x(rb_prefix_t *prefix, char *buf, int buf_len, int with_len)
static char tmp[6]; static char tmp[6];
if(prefix == NULL) if(prefix == NULL)
{ {
strcpy(buf, "(NULL)"); rb_strlcpy(buf, "(NULL)", buf_len);
return (buf); return (buf);
} }
inet_ntop(prefix->family, &prefix->add.sin, buf, buf_len); inet_ntop(prefix->family, &prefix->add.sin, buf, buf_len);

View file

@ -70,12 +70,6 @@ rb_ctime(const time_t t, char *buf, size_t len)
#else #else
tp = gmtime(&t); tp = gmtime(&t);
#endif #endif
if(rb_unlikely(tp == NULL))
{
strcpy(buf, "");
return (buf);
}
if(buf == NULL) if(buf == NULL)
{ {
p = timex; p = timex;
@ -87,6 +81,12 @@ rb_ctime(const time_t t, char *buf, size_t len)
tlen = 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", rb_snprintf(p, tlen, "%s %s %d %02u:%02u:%02u %d",
s_weekdays[tp->tm_wday], s_month[tp->tm_mon], 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); tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec, tp->tm_year + 1900);