]> code.delx.au - gnu-emacs/commitdiff
Add NUL-termination to some uses of strncpy.
authorJim Meyering <meyering@redhat.com>
Wed, 2 May 2012 10:12:13 +0000 (18:12 +0800)
committerChong Yidong <cyd@gnu.org>
Wed, 2 May 2012 10:12:13 +0000 (18:12 +0800)
* 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).

lib-src/ChangeLog
lib-src/pop.c
src/ChangeLog
src/w32font.c

index e58b291ec896b954a65d2b8c4ddc878d06979e1f..8e07193ae0ccd942705586ff89f1ce063c2257e4 100644 (file)
@@ -1,3 +1,8 @@
+2012-05-02  Jim Meyering  <meyering@redhat.com>
+
+       * lib-src/pop.c (pop_stat, pop_list, pop_multi_first, pop_last):
+       NUL-terminate the error buffer (Bug#11372).
+
 2012-04-15  Chong Yidong  <cyd@gnu.org>
 
        * emacsclient.c (decode_options): Move -t -n corner case handling
index 37494d17a44bfe1f34117a93985ee353778a9fde..c4c7f2b4e2f0360fff2ff2c0c2724625685e478a 100644 (file)
@@ -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))
index e2eb95f60d096e1d1962bd58bddd1b6c9cd5ef73..8aa1707cd309814fb7d4ca6ff414c4738437e453 100644 (file)
@@ -1,3 +1,7 @@
+2012-05-02  Jim Meyering  <meyering@redhat.com>
+
+       * w32font.c (fill_in_logfont): NUL-terminate a string (Bug#11372).
+
 2012-04-29  Eli Zaretskii  <eliz@gnu.org>
 
        * xdisp.c (pos_visible_p): If already at a newline from the
index dab9f4c61b480f856c4f6318fcc8b20beebcc6f1..8badace96358f36af0fcbc0eb17485cb85fdafc2 100644 (file)
@@ -2045,8 +2045,11 @@ fill_in_logfont (FRAME_PTR f, LOGFONT *logfont, Lisp_Object font_spec)
         /* Font families are interned, but allow for strings also in case of
            user input.  */
       else if (SYMBOLP (tmp))
-        strncpy (logfont->lfFaceName,
-                SDATA (ENCODE_SYSTEM (SYMBOL_NAME (tmp))), LF_FACESIZE);
+       {
+         strncpy (logfont->lfFaceName,
+                  SDATA (ENCODE_SYSTEM (SYMBOL_NAME (tmp))), LF_FACESIZE);
+         logfont->lfFaceName[LF_FACESIZE-1] = '\0';
+       }
     }
 
   tmp = AREF (font_spec, FONT_ADSTYLE_INDEX);