]> git.eshelyaron.com Git - emacs.git/commitdiff
Do not read unitialized memory in conv_sockaddr_to_lisp
authorDaniel Colascione <dancol@dancol.org>
Sat, 22 Mar 2014 03:04:24 +0000 (20:04 -0700)
committerDaniel Colascione <dancol@dancol.org>
Sat, 22 Mar 2014 03:04:24 +0000 (20:04 -0700)
lisp/ChangeLog
lisp/mail/emacsbug.el
src/ChangeLog
src/process.c

index b35264cdf6b9fca273255e04a639ef0a8bf3d425..214807697e16a323d9c53304592a85a5895e94bd 100644 (file)
@@ -1,3 +1,8 @@
+2014-03-21  Daniel Colascione  <dancol@dancol.org>
+
+       * mail/emacsbug.el (report-emacs-bug): Include memory usage
+       information in bug reports.
+
 2014-03-21  Glenn Morris  <rgm@gnu.org>
 
        * Makefile.in ($(MH_E_DIR)/mh-loaddefs.el)
index 0f72d24ed1e19f4a43b9526c97c9fc795e6a1c1c..b994949e94d825f71b19ce8514bd5d25fd92a167 100644 (file)
@@ -322,6 +322,10 @@ usually do not have translators for other languages.\n\n")))
                 shadows)))
     (insert (format "\nFeatures:\n%s\n" features))
     (fill-region (line-beginning-position 0) (point))
+
+    (insert (format "\nMemory information:\n"))
+    (pp (garbage-collect) (current-buffer))
+    
     ;; This is so the user has to type something in order to send easily.
     (use-local-map (nconc (make-sparse-keymap) (current-local-map)))
     (define-key (current-local-map) "\C-c\C-i" 'info-emacs-bug)
index c491119041f9ea57468a9175a2eb9350e656fe2b..504716f8915305b280176f370d0d0dd4b19f2e34 100644 (file)
@@ -1,3 +1,9 @@
+2014-03-22  Daniel Colascione  <dancol@dancol.org>
+
+       * process.c (conv_sockaddr_to_lisp): When extracting the string
+       names of AF_LOCAL sockets, stop before reading uninitialized
+       memory.
+
 2014-03-21  Daniel Colascione  <dancol@dancol.org>
 
        * xterm.c (x_bitmap_icon): Stop reading the icon bitmap from disk
index 187627dd85ab725c9a85905f3009efefdc7d4b71..10a2984a05358d03a1d6db9801abe0c09a048328 100644 (file)
@@ -2010,10 +2010,22 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, int len)
     case AF_LOCAL:
       {
        struct sockaddr_un *sockun = (struct sockaddr_un *) sa;
-       for (i = 0; i < sizeof (sockun->sun_path); i++)
-         if (sockun->sun_path[i] == 0)
-           break;
-       return make_unibyte_string (sockun->sun_path, i);
+        ptrdiff_t name_length = len - offsetof (struct sockaddr_un, sun_path);
+        /* If the first byte is NUL, the name is a Linux abstract
+           socket name, and the name can contain embedded NULs.  If
+           it's not, we have a NUL-terminated string.  Be careful not
+           to walk past the end of the object looking for the name
+           terminator, however.  */
+        if (name_length > 0 && sockun->sun_path[0] != '\0')
+          {
+            const char* terminator =
+              memchr (sockun->sun_path, '\0', name_length);
+
+            if (terminator)
+              name_length = terminator - (const char*) sockun->sun_path;
+          }
+
+       return make_unibyte_string (sockun->sun_path, name_length);
       }
 #endif
     default: