]> git.eshelyaron.com Git - emacs.git/commitdiff
* dbusbind.c (XD_ERROR): Don't arbitrarily truncate string.
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 Jun 2011 18:32:55 +0000 (11:32 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 19 Jun 2011 18:32:55 +0000 (11:32 -0700)
(XD_DEBUG_MESSAGE): Don't waste a byte.

src/ChangeLog
src/dbusbind.c

index 89d518a1a56cf4a565fbb2771cd731c1b9c7e21b..3a7cad71c35939dca2abc32236c52f3c7f0b676e 100644 (file)
@@ -1,5 +1,8 @@
 2011-06-19  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * dbusbind.c (XD_ERROR): Don't arbitrarily truncate string.
+       (XD_DEBUG_MESSAGE): Don't waste a byte.
+
        * callproc.c (getenv_internal_1, getenv_internal)
        (Fgetenv_internal):
        * buffer.c (init_buffer): Don't assume string length fits in 'int'.
index f662d5b38a26ef06fcd6bd0d93400ac64f31b2c1..302b93146fd68b40ec33bd5c31472652e1960707 100644 (file)
@@ -111,13 +111,12 @@ static int xd_in_read_queued_messages = 0;
 /* Raise a Lisp error from a D-Bus ERROR.  */
 #define XD_ERROR(error)                                                        \
   do {                                                                 \
-    char s[1024];                                                      \
-    strncpy (s, error.message, 1023);                                  \
-    dbus_error_free (&error);                                          \
     /* Remove the trailing newline.  */                                        \
-    if (strchr (s, '\n') != NULL)                                      \
-      s[strlen (s) - 1] = '\0';                                                \
-    XD_SIGNAL1 (build_string (s));                                     \
+    char const *mess = error.message;                                  \
+    char const *nl = strchr (mess, '\n');                              \
+    Lisp_Object err = make_string (mess, nl ? nl - mess : strlen (mess)); \
+    dbus_error_free (&error);                                          \
+    XD_SIGNAL1 (err);                                                  \
   } while (0)
 
 /* Macros for debugging.  In order to enable them, build with
@@ -126,7 +125,7 @@ static int xd_in_read_queued_messages = 0;
 #define XD_DEBUG_MESSAGE(...)          \
   do {                                 \
     char s[1024];                      \
-    snprintf (s, 1023, __VA_ARGS__);   \
+    snprintf (s, sizeof s, __VA_ARGS__); \
     printf ("%s: %s\n", __func__, s);  \
     message ("%s: %s", __func__, s);   \
   } while (0)