emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/emacs-24 r107934: Add NUL-termination to so


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-24 r107934: Add NUL-termination to some uses of strncpy.
Date: Wed, 02 May 2012 18:12:13 +0800
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107934
fixes bug(s): http://debbugs.gnu.org/11372
author: Jim Meyering  <address@hidden>
committer: Chong Yidong <address@hidden>
branch nick: emacs-24
timestamp: Wed 2012-05-02 18:12:13 +0800
message:
  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).
modified:
  lib-src/ChangeLog
  lib-src/pop.c
  src/ChangeLog
  src/w32font.c
=== modified file 'lib-src/ChangeLog'
--- a/lib-src/ChangeLog 2012-04-15 08:49:24 +0000
+++ b/lib-src/ChangeLog 2012-05-02 10:12:13 +0000
@@ -1,3 +1,8 @@
+2012-05-02  Jim Meyering  <address@hidden>
+
+       * 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  <address@hidden>
 
        * emacsclient.c (decode_options): Move -t -n corner case handling

=== modified file 'lib-src/pop.c'
--- a/lib-src/pop.c     2012-01-19 07:21:25 +0000
+++ b/lib-src/pop.c     2012-05-02 10:12:13 +0000
@@ -346,6 +346,7 @@
       if (0 == strncmp (fromserver, "-ERR", 4))
        {
          strncpy (pop_error, fromserver, ERROR_MAX);
+         pop_error[ERROR_MAX-1] = '\0';
        }
       else
        {
@@ -447,7 +448,10 @@
       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 @@
   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 @@
   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))

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-04-29 17:19:08 +0000
+++ b/src/ChangeLog     2012-05-02 10:12:13 +0000
@@ -1,3 +1,7 @@
+2012-05-02  Jim Meyering  <address@hidden>
+
+       * w32font.c (fill_in_logfont): NUL-terminate a string (Bug#11372).
+
 2012-04-29  Eli Zaretskii  <address@hidden>
 
        * xdisp.c (pos_visible_p): If already at a newline from the

=== modified file 'src/w32font.c'
--- a/src/w32font.c     2012-01-19 07:21:25 +0000
+++ b/src/w32font.c     2012-05-02 10:12:13 +0000
@@ -2045,8 +2045,11 @@
         /* 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);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]