aboutsummaryrefslogtreecommitdiffstats
path: root/capture.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-06-15 01:36:46 +0000
committerGuy Harris <guy@alum.mit.edu>2001-06-15 01:36:46 +0000
commitcb1260ab9f79a011f376745d448091eecb5392d2 (patch)
treed8e5644f3b68ca90334340e14b2b00c6c313bc5b /capture.c
parent535bd4f9138447ef92d31e9e4bab78478177a020 (diff)
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.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/capture.c b/capture.c
index 9453fbbc57..85b8aada0e 100644
--- a/capture.c
+++ b/capture.c
@@ -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]);