summaryrefslogtreecommitdiff
path: root/lib-src/pop.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-05-02 18:12:13 +0800
committerChong Yidong <cyd@gnu.org>2012-05-02 18:12:13 +0800
commitbf98199cf1bea244378538d60838f81cb3a34b49 (patch)
treeee8ffe8445eb073346878b4eb2731264c97c599e /lib-src/pop.c
parentcd3771a08b8a1fed5aa91eb2ac559d41801668ea (diff)
downloademacs-bf98199cf1bea244378538d60838f81cb3a34b49.tar.gz
Add NUL-termination to some uses of strncpy.
* lib-src/pop.c (pop_stat, pop_list, pop_multi_first, pop_last): NUL-terminate the error buffer. * src/w32font.c (fill_in_logfont): NUL-terminate a string (Bug#11372).
Diffstat (limited to 'lib-src/pop.c')
-rw-r--r--lib-src/pop.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib-src/pop.c b/lib-src/pop.c
index 37494d17a44..c4c7f2b4e2f 100644
--- a/lib-src/pop.c
+++ b/lib-src/pop.c
@@ -346,6 +346,7 @@ pop_stat (popserver server, int *count, int *size)
if (0 == strncmp (fromserver, "-ERR", 4))
{
strncpy (pop_error, fromserver, ERROR_MAX);
+ pop_error[ERROR_MAX-1] = '\0';
}
else
{
@@ -447,7 +448,10 @@ pop_list (popserver server, int message, int **IDs, int **sizes)
if (strncmp (fromserver, "+OK ", 4))
{
if (! strncmp (fromserver, "-ERR", 4))
- strncpy (pop_error, fromserver, ERROR_MAX);
+ {
+ strncpy (pop_error, fromserver, ERROR_MAX);
+ pop_error[ERROR_MAX-1] = '\0';
+ }
else
{
strcpy (pop_error,
@@ -687,6 +691,7 @@ pop_multi_first (popserver server, const char *command, char **response)
if (0 == strncmp (*response, "-ERR", 4))
{
strncpy (pop_error, *response, ERROR_MAX);
+ pop_error[ERROR_MAX-1] = '\0';
return (-1);
}
else if (0 == strncmp (*response, "+OK", 3))
@@ -860,6 +865,7 @@ pop_last (popserver server)
if (! strncmp (fromserver, "-ERR", 4))
{
strncpy (pop_error, fromserver, ERROR_MAX);
+ pop_error[ERROR_MAX-1] = '\0';
return (-1);
}
else if (strncmp (fromserver, "+OK ", 4))