From e40c7ab1dcf863d230af94cf0bbb30335fe0d5eb Mon Sep 17 00:00:00 2001 From: Chris Maynard Date: Sat, 9 Jun 2012 03:41:23 +0000 Subject: [PATCH] Be sure to specify FORMAT_MESSAGE_IGNORE_INSERTS in the dwFlags arg to all FormatMessage() calls where FORMAT_MESSAGE_FROM_SYSTEM is also specified. (Ref: http://blogs.msdn.com/b/oldnewthing/archive/2007/11/28/6564257.aspx) svn path=/trunk/; revision=43172 --- capture_sync.c | 6 +++--- epan/filesystem.c | 2 +- rawshark.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/capture_sync.c b/capture_sync.c index 366a566f82..2ae16fdf99 100644 --- a/capture_sync.c +++ b/capture_sync.c @@ -225,8 +225,8 @@ win32strerror(DWORD error) size_t errlen; char *p; - FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, errbuf, - ERRBUF_SIZE, NULL); + FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, error, 0, errbuf, ERRBUF_SIZE, NULL); /* * "FormatMessage()" "helpfully" sticks CR/LF at the end of the @@ -1637,7 +1637,7 @@ sync_pipe_input_cb(gint source, gpointer user_data) "standard output", as the capture file. */ sync_pipe_stop(capture_opts); capture_input_closed(capture_opts, NULL); - return FALSE; + //return FALSE; } break; case SP_PACKET_COUNT: diff --git a/epan/filesystem.c b/epan/filesystem.c index 2e744455ca..ea41a10eda 100644 --- a/epan/filesystem.c +++ b/epan/filesystem.c @@ -305,7 +305,7 @@ init_progfile_dir(const char *arg0 * Oh, well. Return an indication of the error. */ error = GetLastError(); - if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, + if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, 0, (LPTSTR) &msg_w, 0, NULL) == 0) { /* * Gak. We can't format the message. diff --git a/rawshark.c b/rawshark.c index 7604627a98..719eba1870 100644 --- a/rawshark.c +++ b/rawshark.c @@ -321,7 +321,7 @@ raw_pipe_open(const char *pipe_name) err = GetLastError(); if (err != ERROR_PIPE_BUSY) { - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, 0, (LPTSTR) &err_str, 0, NULL); fprintf(stderr, "rawshark: \"%s\" could not be opened: %s (error %d)\n", pipe_name, utf_16to8(err_str), err); @@ -331,7 +331,7 @@ raw_pipe_open(const char *pipe_name) if (!WaitNamedPipe(utf_8to16(pipe_name), 30 * 1000)) { err = GetLastError(); - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, err, 0, (LPTSTR) &err_str, 0, NULL); fprintf(stderr, "rawshark: \"%s\" could not be waited for: %s (error %d)\n", pipe_name, utf_16to8(err_str), err);