diff options
author | Guy Harris <guy@alum.mit.edu> | 2001-06-15 01:36:46 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2001-06-15 01:36:46 +0000 |
commit | cb1260ab9f79a011f376745d448091eecb5392d2 (patch) | |
tree | d8e5644f3b68ca90334340e14b2b00c6c313bc5b /capture.c | |
parent | 535bd4f9138447ef92d31e9e4bab78478177a020 (diff) | |
download | wireshark-cb1260ab9f79a011f376745d448091eecb5392d2.tar.gz wireshark-cb1260ab9f79a011f376745d448091eecb5392d2.tar.bz2 wireshark-cb1260ab9f79a011f376745d448091eecb5392d2.zip |
If the capture child process sends the parent an error message with a
byte count of zero, don't bother allocating a buffer for that message,
as we wouldn't do anything with that buffer.
Null-terminate the error message once we read it, before using it as a
string.
svn path=/trunk/; revision=3551
Diffstat (limited to 'capture.c')
-rw-r--r-- | capture.c | 33 |
1 files changed, 18 insertions, 15 deletions
@@ -1,7 +1,7 @@ /* capture.c * Routines for packet capture windows * - * $Id: capture.c,v 1.151 2001/06/05 07:38:33 guy Exp $ + * $Id: capture.c,v 1.152 2001/06/15 01:36:46 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -536,27 +536,30 @@ do_capture(char *capfile_name) } else { /* Failure - the child process sent us a message indicating what the problem was. */ - msg = g_malloc(byte_count + 1); - if (msg == NULL) { - simple_dialog(ESD_TYPE_WARN, NULL, - "Capture child process failed, but its error message was too big."); - } else if (byte_count == 0) { - /* Zero-length message? */ + if (byte_count == 0) { + /* Zero-length message? */ simple_dialog(ESD_TYPE_WARN, NULL, "Capture child process failed, but its error message was empty."); } else { - i = read(sync_pipe[READ], msg, byte_count); - if (i < 0) { + msg = g_malloc(byte_count + 1); + if (msg == NULL) { simple_dialog(ESD_TYPE_WARN, NULL, + "Capture child process failed, but its error message was too big."); + } else { + i = read(sync_pipe[READ], msg, byte_count); + msg[byte_count] = '\0'; + if (i < 0) { + simple_dialog(ESD_TYPE_WARN, NULL, "Capture child process failed: Error %s reading its error message.", strerror(errno)); - } else if (i == 0) { - simple_dialog(ESD_TYPE_WARN, NULL, + } else if (i == 0) { + simple_dialog(ESD_TYPE_WARN, NULL, "Capture child process failed: EOF reading its error message."); - wait_for_child(FALSE); - } else - simple_dialog(ESD_TYPE_WARN, NULL, msg); - g_free(msg); + wait_for_child(FALSE); + } else + simple_dialog(ESD_TYPE_WARN, NULL, msg); + g_free(msg); + } /* Close the sync pipe. */ close(sync_pipe[READ]); |