diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/dbusbind.c | 22 |
2 files changed, 20 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 1de15f4796e..e6c58903f03 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | 2011-08-29 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-08-30 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | sprintf-related integer and memory overflow issues. | 3 | sprintf-related integer and memory overflow issues. |
| 4 | 4 | ||
| @@ -20,7 +20,8 @@ | |||
| 20 | (esprintf, esnprintf, exprintf, evxprintf): New decls. | 20 | (esprintf, esnprintf, exprintf, evxprintf): New decls. |
| 21 | * window.h (command_loop_level, minibuf_level): Reflect API changes. | 21 | * window.h (command_loop_level, minibuf_level): Reflect API changes. |
| 22 | 22 | ||
| 23 | * dbusbind.c (xd_signature, Fdbus_register_signal): | 23 | * dbusbind.c (signature_cat): New function. |
| 24 | (xd_signature, Fdbus_register_signal): | ||
| 24 | Do not overrun buffer; instead, report string overflow. | 25 | Do not overrun buffer; instead, report string overflow. |
| 25 | 26 | ||
| 26 | * dispnew.c (add_window_display_history): Don't overrun buffer. | 27 | * dispnew.c (add_window_display_history): Don't overrun buffer. |
diff --git a/src/dbusbind.c b/src/dbusbind.c index 005d521c1db..f7422ca2ddc 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c | |||
| @@ -259,6 +259,18 @@ xd_symbol_to_dbus_type (Lisp_Object object) | |||
| 259 | } \ | 259 | } \ |
| 260 | while (0) | 260 | while (0) |
| 261 | 261 | ||
| 262 | /* Append to SIGNATURE the a copy of X, making sure SIGNATURE does | ||
| 263 | not become too long. */ | ||
| 264 | static void | ||
| 265 | signature_cat (char *signature, char const *x) | ||
| 266 | { | ||
| 267 | ptrdiff_t siglen = strlen (signature); | ||
| 268 | ptrdiff_t xlen = strlen (x); | ||
| 269 | if (DBUS_MAXIMUM_SIGNATURE_LENGTH - xlen <= siglen) | ||
| 270 | string_overflow (); | ||
| 271 | strcat (signature, x); | ||
| 272 | } | ||
| 273 | |||
| 262 | /* Compute SIGNATURE of OBJECT. It must have a form that it can be | 274 | /* Compute SIGNATURE of OBJECT. It must have a form that it can be |
| 263 | used in dbus_message_iter_open_container. DTYPE is the DBusType | 275 | used in dbus_message_iter_open_container. DTYPE is the DBusType |
| 264 | the object is related to. It is passed as argument, because it | 276 | the object is related to. It is passed as argument, because it |
| @@ -388,10 +400,10 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis | |||
| 388 | { | 400 | { |
| 389 | subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt)); | 401 | subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt)); |
| 390 | xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt))); | 402 | xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt))); |
| 391 | strcat (signature, x); | 403 | signature_cat (signature, x); |
| 392 | elt = CDR_SAFE (XD_NEXT_VALUE (elt)); | 404 | elt = CDR_SAFE (XD_NEXT_VALUE (elt)); |
| 393 | } | 405 | } |
| 394 | strcat (signature, DBUS_STRUCT_END_CHAR_AS_STRING); | 406 | signature_cat (signature, DBUS_STRUCT_END_CHAR_AS_STRING); |
| 395 | break; | 407 | break; |
| 396 | 408 | ||
| 397 | case DBUS_TYPE_DICT_ENTRY: | 409 | case DBUS_TYPE_DICT_ENTRY: |
| @@ -412,7 +424,7 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis | |||
| 412 | elt = XD_NEXT_VALUE (elt); | 424 | elt = XD_NEXT_VALUE (elt); |
| 413 | subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt)); | 425 | subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt)); |
| 414 | xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt))); | 426 | xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt))); |
| 415 | strcat (signature, x); | 427 | signature_cat (signature, x); |
| 416 | 428 | ||
| 417 | if (!XD_BASIC_DBUS_TYPE (subtype)) | 429 | if (!XD_BASIC_DBUS_TYPE (subtype)) |
| 418 | wrong_type_argument (intern ("D-Bus"), CAR_SAFE (XD_NEXT_VALUE (elt))); | 430 | wrong_type_argument (intern ("D-Bus"), CAR_SAFE (XD_NEXT_VALUE (elt))); |
| @@ -421,14 +433,14 @@ xd_signature (char *signature, unsigned int dtype, unsigned int parent_type, Lis | |||
| 421 | elt = CDR_SAFE (XD_NEXT_VALUE (elt)); | 433 | elt = CDR_SAFE (XD_NEXT_VALUE (elt)); |
| 422 | subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt)); | 434 | subtype = XD_OBJECT_TO_DBUS_TYPE (CAR_SAFE (elt)); |
| 423 | xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt))); | 435 | xd_signature (x, subtype, dtype, CAR_SAFE (XD_NEXT_VALUE (elt))); |
| 424 | strcat (signature, x); | 436 | signature_cat (signature, x); |
| 425 | 437 | ||
| 426 | if (!NILP (CDR_SAFE (XD_NEXT_VALUE (elt)))) | 438 | if (!NILP (CDR_SAFE (XD_NEXT_VALUE (elt)))) |
| 427 | wrong_type_argument (intern ("D-Bus"), | 439 | wrong_type_argument (intern ("D-Bus"), |
| 428 | CAR_SAFE (CDR_SAFE (XD_NEXT_VALUE (elt)))); | 440 | CAR_SAFE (CDR_SAFE (XD_NEXT_VALUE (elt)))); |
| 429 | 441 | ||
| 430 | /* Closing signature. */ | 442 | /* Closing signature. */ |
| 431 | strcat (signature, DBUS_DICT_ENTRY_END_CHAR_AS_STRING); | 443 | signature_cat (signature, DBUS_DICT_ENTRY_END_CHAR_AS_STRING); |
| 432 | break; | 444 | break; |
| 433 | 445 | ||
| 434 | default: | 446 | default: |