diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-06-09 02:09:10 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-06-09 02:09:10 +0200 |
commit | 07fdd581bbdd550df65acd91e4c2dd6e2f52385e (patch) | |
tree | d77b4918e4678bf139abc108b32164d64e94abdb /src | |
parent | put process names in quotes and print exit status and termination signal on crashed processes (diff) | |
download | mds-07fdd581bbdd550df65acd91e4c2dd6e2f52385e.tar.gz mds-07fdd581bbdd550df65acd91e4c2dd6e2f52385e.tar.bz2 mds-07fdd581bbdd550df65acd91e4c2dd6e2f52385e.tar.xz |
m + fix echo server crash
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/mds-echo.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/mds-echo.c b/src/mds-echo.c index c9087c5..f2b1f82 100644 --- a/src/mds-echo.c +++ b/src/mds-echo.c @@ -276,6 +276,7 @@ int echo_message(void) #undef __get_header + if ((recv_client_id == NULL) || (strequals(recv_client_id, "0:0"))) { eprint("received message from anonymous sender, ignoring."); @@ -289,7 +290,7 @@ int echo_message(void) n = 1 + strlen("To: \nIn response to: \nMessage ID: \n\n"); n += strlen(recv_client_id) + strlen(recv_message_id) + 10; - if (recv_length) + if (recv_length != NULL) n += strlen(recv_length) + 1; if ((echo_buffer_size < n) || (echo_buffer_size * 4 > n)) @@ -302,14 +303,12 @@ int echo_message(void) } } - sprintf(echo_buffer, "To: %s\nIn response to:%s\nMessage ID: " PRIi32 "\n%s%s\n", + sprintf(echo_buffer, "To: %s\nIn response to: %s\nMessage ID: %" PRIi32 "\n%s%s\n", recv_client_id, recv_message_id, message_id, recv_length == NULL ? "" : recv_length, recv_length == NULL ? "" : "\n"); - message_id += 1; - if (message_id < 0) - message_id = 0; + message_id = message_id == INT32_MAX ? 0 : (message_id + 1); if (full_send(echo_buffer, n - 1)) return 1; |