aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Meyering2012-05-02 18:12:13 +0800
committerChong Yidong2012-05-02 18:12:13 +0800
commitbf98199cf1bea244378538d60838f81cb3a34b49 (patch)
treeee8ffe8445eb073346878b4eb2731264c97c599e
parentcd3771a08b8a1fed5aa91eb2ac559d41801668ea (diff)
downloademacs-bf98199cf1bea244378538d60838f81cb3a34b49.tar.gz
emacs-bf98199cf1bea244378538d60838f81cb3a34b49.zip
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).
-rw-r--r--lib-src/ChangeLog5
-rw-r--r--lib-src/pop.c8
-rw-r--r--src/ChangeLog4
-rw-r--r--src/w32font.c7
4 files changed, 21 insertions, 3 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index e58b291ec89..8e07193ae0c 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,8 @@
12012-05-02 Jim Meyering <meyering@redhat.com>
2
3 * lib-src/pop.c (pop_stat, pop_list, pop_multi_first, pop_last):
4 NUL-terminate the error buffer (Bug#11372).
5
12012-04-15 Chong Yidong <cyd@gnu.org> 62012-04-15 Chong Yidong <cyd@gnu.org>
2 7
3 * emacsclient.c (decode_options): Move -t -n corner case handling 8 * emacsclient.c (decode_options): Move -t -n corner case handling
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)
346 if (0 == strncmp (fromserver, "-ERR", 4)) 346 if (0 == strncmp (fromserver, "-ERR", 4))
347 { 347 {
348 strncpy (pop_error, fromserver, ERROR_MAX); 348 strncpy (pop_error, fromserver, ERROR_MAX);
349 pop_error[ERROR_MAX-1] = '\0';
349 } 350 }
350 else 351 else
351 { 352 {
@@ -447,7 +448,10 @@ pop_list (popserver server, int message, int **IDs, int **sizes)
447 if (strncmp (fromserver, "+OK ", 4)) 448 if (strncmp (fromserver, "+OK ", 4))
448 { 449 {
449 if (! strncmp (fromserver, "-ERR", 4)) 450 if (! strncmp (fromserver, "-ERR", 4))
450 strncpy (pop_error, fromserver, ERROR_MAX); 451 {
452 strncpy (pop_error, fromserver, ERROR_MAX);
453 pop_error[ERROR_MAX-1] = '\0';
454 }
451 else 455 else
452 { 456 {
453 strcpy (pop_error, 457 strcpy (pop_error,
@@ -687,6 +691,7 @@ pop_multi_first (popserver server, const char *command, char **response)
687 if (0 == strncmp (*response, "-ERR", 4)) 691 if (0 == strncmp (*response, "-ERR", 4))
688 { 692 {
689 strncpy (pop_error, *response, ERROR_MAX); 693 strncpy (pop_error, *response, ERROR_MAX);
694 pop_error[ERROR_MAX-1] = '\0';
690 return (-1); 695 return (-1);
691 } 696 }
692 else if (0 == strncmp (*response, "+OK", 3)) 697 else if (0 == strncmp (*response, "+OK", 3))
@@ -860,6 +865,7 @@ pop_last (popserver server)
860 if (! strncmp (fromserver, "-ERR", 4)) 865 if (! strncmp (fromserver, "-ERR", 4))
861 { 866 {
862 strncpy (pop_error, fromserver, ERROR_MAX); 867 strncpy (pop_error, fromserver, ERROR_MAX);
868 pop_error[ERROR_MAX-1] = '\0';
863 return (-1); 869 return (-1);
864 } 870 }
865 else if (strncmp (fromserver, "+OK ", 4)) 871 else if (strncmp (fromserver, "+OK ", 4))
diff --git a/src/ChangeLog b/src/ChangeLog
index e2eb95f60d0..8aa1707cd30 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
12012-05-02 Jim Meyering <meyering@redhat.com>
2
3 * w32font.c (fill_in_logfont): NUL-terminate a string (Bug#11372).
4
12012-04-29 Eli Zaretskii <eliz@gnu.org> 52012-04-29 Eli Zaretskii <eliz@gnu.org>
2 6
3 * xdisp.c (pos_visible_p): If already at a newline from the 7 * xdisp.c (pos_visible_p): If already at a newline from the
diff --git a/src/w32font.c b/src/w32font.c
index dab9f4c61b4..8badace9635 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -2045,8 +2045,11 @@ fill_in_logfont (FRAME_PTR f, LOGFONT *logfont, Lisp_Object font_spec)
2045 /* Font families are interned, but allow for strings also in case of 2045 /* Font families are interned, but allow for strings also in case of
2046 user input. */ 2046 user input. */
2047 else if (SYMBOLP (tmp)) 2047 else if (SYMBOLP (tmp))
2048 strncpy (logfont->lfFaceName, 2048 {
2049 SDATA (ENCODE_SYSTEM (SYMBOL_NAME (tmp))), LF_FACESIZE); 2049 strncpy (logfont->lfFaceName,
2050 SDATA (ENCODE_SYSTEM (SYMBOL_NAME (tmp))), LF_FACESIZE);
2051 logfont->lfFaceName[LF_FACESIZE-1] = '\0';
2052 }
2050 } 2053 }
2051 2054
2052 tmp = AREF (font_spec, FONT_ADSTYLE_INDEX); 2055 tmp = AREF (font_spec, FONT_ADSTYLE_INDEX);