From: Antony Dovgal Date: Thu, 28 Dec 2006 20:45:20 +0000 (+0000) Subject: use strlcpy() X-Git-Tag: RELEASE_1_0_0RC1~459 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bef17c425a767099bb011b294b1abbc34025a7d3;p=php use strlcpy() --- diff --git a/ext/fdf/fdf.c b/ext/fdf/fdf.c index c337467fea..842fd54c83 100644 --- a/ext/fdf/fdf.c +++ b/ext/fdf/fdf.c @@ -1726,8 +1726,7 @@ PHP_FUNCTION(fdf_get_attachment) { RETURN_FALSE; } - strncpy(pathbuf , savepath, MAXPATHLEN-1); - pathbuf[MAXPATHLEN-1] = '\0'; + strlcpy(pathbuf, savepath, sizeof(pathbuf)); if(0 == stat(pathbuf, &statBuf)) { is_dir = S_ISDIR(statBuf.st_mode); diff --git a/ext/mime_magic/mime_magic.c b/ext/mime_magic/mime_magic.c index 91453e7c46..3dcf5fb7e7 100644 --- a/ext/mime_magic/mime_magic.c +++ b/ext/mime_magic/mime_magic.c @@ -730,9 +730,7 @@ static int parse(char *l, int lineno) return -1; } - strncpy(m->desc, l, sizeof(m->desc) - 1); - m->desc[sizeof(m->desc) - 1] = '\0'; - + strlcpy(m->desc, l, sizeof(m->desc)); return 0; }