diff options
author | John Thacker <johnthacker@gmail.com> | 2023-12-07 19:58:21 -0500 |
---|---|---|
committer | John Thacker <johnthacker@gmail.com> | 2023-12-08 15:49:05 +0000 |
commit | 4db3e8f3f1158e79b53981116db88382db5b6ac7 (patch) | |
tree | 524e24122de47dd02c56cf8831eae5cd6f83d876 /rawshark.c | |
parent | 0bcd2b6e6f296483c0272ceaa52d1b464d13d684 (diff) |
Capture: Check to see if the interface name is a Windows Named Pipe
Named pipes have special names on Windows
( https://learn.microsoft.com/en-us/windows/win32/ipc/pipe-names )
If we're on Windows, and the interface name given has such a name,
assume it is a pipe and don't bother retrieving the interface list.
Dumpcap and rawshark already have identical code for testing if an
interface name is a pipe. Move that into win32-utils and have
capture_opts, dumpcap, and rawshark all use the common function.
Fix #17721
Diffstat (limited to 'rawshark.c')
-rw-r--r-- | rawshark.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/rawshark.c b/rawshark.c index 9bdb5aa2bd..15c21aceb6 100644 --- a/rawshark.c +++ b/rawshark.c @@ -55,6 +55,7 @@ #ifdef _WIN32 #include <wsutil/unicode-utils.h> +#include <wsutil/win32-utils.h> #endif #include "globals.h" @@ -238,7 +239,6 @@ raw_pipe_open(const char *pipe_name) #ifndef _WIN32 ws_statb64 pipe_stat; #else - char *pncopy, *pos = NULL; DWORD err; wchar_t *err_str; HANDLE hPipe = NULL; @@ -286,20 +286,7 @@ raw_pipe_open(const char *pipe_name) return -1; } #else /* _WIN32 */ -#define PIPE_STR "\\pipe\\" - /* Under Windows, named pipes _must_ have the form - * "\\<server>\pipe\<pipe_name>". <server> may be "." for localhost. - */ - pncopy = g_strdup(pipe_name); - if (strstr(pncopy, "\\\\") == pncopy) { - pos = strchr(pncopy + 3, '\\'); - if (pos && g_ascii_strncasecmp(pos, PIPE_STR, strlen(PIPE_STR)) != 0) - pos = NULL; - } - - g_free(pncopy); - - if (!pos) { + if (!win32_is_pipe_name(pipe_name)) { fprintf(stderr, "rawshark: \"%s\" is neither an interface nor a pipe\n", pipe_name); return -1; |