[Git][NTPsec/ntpsec][master] Several strncpy/strncat => strlcpy/strlcat, fix #542
Hal Murray
gitlab at mg.gitlab.com
Thu Jan 31 05:00:23 UTC 2019
Hal Murray pushed to branch master at NTPsec / ntpsec
Commits:
c813ce90 by Hal Murray at 2019-01-31T04:56:23Z
Several strncpy/strncat => strlcpy/strlcat, fix #542
- - - - -
2 changed files:
- libntp/authreadkeys.c
- libntp/prettydate.c
Changes:
=====================================
libntp/authreadkeys.c
=====================================
@@ -66,9 +66,9 @@ nexttok(
static char*
try_cmac(const char *upcased, char* namebuf) {
- strncpy(namebuf, upcased, NAMEBUFSIZE);
+ strlcpy(namebuf, upcased, NAMEBUFSIZE);
if ((strcmp(namebuf, "AES") == 0) || (strcmp(namebuf, "AES128CMAC") == 0))
- strncpy(namebuf, "AES-128", NAMEBUFSIZE);
+ strlcpy(namebuf, "AES-128", NAMEBUFSIZE);
strlcat(namebuf, "-CBC", NAMEBUFSIZE);
namebuf[NAMEBUFSIZE-1] = '\0';
if (0) msyslog(LOG_INFO, "DEBUG try_cmac: %s=>%s", upcased, namebuf);
@@ -79,12 +79,12 @@ try_cmac(const char *upcased, char* namebuf) {
static char*
try_digest(char *upcased, char *namebuf) {
- strncpy(namebuf, upcased, NAMEBUFSIZE);
+ strlcpy(namebuf, upcased, NAMEBUFSIZE);
if (EVP_get_digestbyname(namebuf) != NULL)
return namebuf;
if ('M' == upcased[0]) {
/* hack for backward compatibility */
- strncpy(namebuf, "MD5", NAMEBUFSIZE);
+ strlcpy(namebuf, "MD5", NAMEBUFSIZE);
if (EVP_get_digestbyname(namebuf) != NULL)
return namebuf;
}
=====================================
libntp/prettydate.c
=====================================
@@ -157,13 +157,13 @@ common_prettydate(
(unsigned long)lfpuint(ts), (unsigned long)lfpfrac(ts),
jd.year, jd.month, jd.monthday,
jd.hour, jd.minute, jd.second, msec);
- strncat(bp, "Z", LIB_BUFLENGTH);
+ strlcat(bp, "Z", LIB_BUFLENGTH);
} else {
snprintf(bp, LIB_BUFLENGTH, pfmt,
(unsigned long)lfpuint(ts), (unsigned long)lfpfrac(ts),
1900 + tm->tm_year, tm->tm_mon+1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec, msec);
- strncat(bp, "Z", LIB_BUFLENGTH);
+ strlcat(bp, "Z", LIB_BUFLENGTH);
}
return bp;
}
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/c813ce90c9c4302afdc7d63b4661458ae2506da9
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/c813ce90c9c4302afdc7d63b4661458ae2506da9
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20190131/1f86a05a/attachment-0001.html>
More information about the vc
mailing list