diff --git a/caputils/capture-pcap-util.c b/caputils/capture-pcap-util.c index 0eedf71bf9..74f5b1ce03 100644 --- a/caputils/capture-pcap-util.c +++ b/caputils/capture-pcap-util.c @@ -67,6 +67,7 @@ #include "log.h" #include +#include #ifndef _WIN32 #include @@ -85,14 +86,6 @@ #include #endif -/* - * Standard secondary message for unexpected errors. - */ -static const char please_report[] = - "Please report this to the Wireshark developers.\n" - "https://bugs.wireshark.org/\n" - "(This is not a crash; please do not report it as such.)"; - /* * Given an interface name, find the "friendly name" and interface * type for the interface. @@ -977,7 +970,8 @@ set_pcap_datalink(pcap_t *pcap_h, int datalink, char *name, * tell the user to tell the Wireshark developers about it. */ if (strstr(set_datalink_err_str, "is not one of the DLTs supported by this device") == NULL) - g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len, please_report); + g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len, + "%s", please_report_bug()); else secondary_errmsg[0] = '\0'; return FALSE; diff --git a/dumpcap.c b/dumpcap.c index c21967d2cf..a706132f93 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -86,6 +86,7 @@ #include "wsutil/str_util.h" #include "wsutil/inet_addr.h" #include "wsutil/time_util.h" +#include "wsutil/please_report_bug.h" #include "caputils/ws80211_utils.h" @@ -326,14 +327,6 @@ typedef struct _pcap_queue_element { u_char *pd; } pcap_queue_element; -/* - * Standard secondary message for unexpected errors. - */ -static const char please_report[] = - "Please report this to the Wireshark developers.\n" - "https://bugs.wireshark.org/\n" - "(This is not a crash; please do not report it as such.)"; - /* * This needs to be static, so that the SIGINT handler can clear the "go" * flag and for saved_shb_idb_lock. @@ -2774,7 +2767,7 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld, "Couldn't initialize Windows Sockets: error %d", err); break; } - g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len, please_report); + g_snprintf(secondary_errmsg, (gulong) secondary_errmsg_len, please_report_bug()); return FALSE; } #endif @@ -3342,7 +3335,7 @@ capture_loop_dispatch(loop_data *ld, if (sel_ret < 0 && errno != EINTR) { g_snprintf(errmsg, errmsg_len, "Unexpected error from select: %s", g_strerror(errno)); - report_capture_error(errmsg, please_report); + report_capture_error(errmsg, please_report_bug()); ld->go = FALSE; } } @@ -3415,7 +3408,7 @@ capture_loop_dispatch(loop_data *ld, if (sel_ret < 0 && errno != EINTR) { g_snprintf(errmsg, errmsg_len, "Unexpected error from select: %s", g_strerror(errno)); - report_capture_error(errmsg, please_report); + report_capture_error(errmsg, please_report_bug()); ld->go = FALSE; } } @@ -3912,7 +3905,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct case INITFILTER_OTHER_ERROR: g_snprintf(errmsg, sizeof(errmsg), "Can't install filter (%s).", pcap_geterr(pcap_src->pcap_h)); - g_snprintf(secondary_errmsg, sizeof(secondary_errmsg), "%s", please_report); + g_snprintf(secondary_errmsg, sizeof(secondary_errmsg), "%s", please_report_bug()); goto error; } } @@ -4164,7 +4157,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct } else { g_snprintf(errmsg, sizeof(errmsg), "Error while capturing packets: %s", cap_err_str); - report_capture_error(errmsg, please_report); + report_capture_error(errmsg, please_report_bug()); } break; } else if (pcap_src->from_cap_pipe && pcap_src->cap_pipe_err == PIPERR) { @@ -4236,7 +4229,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct g_snprintf(errmsg, sizeof(errmsg), "Can't get packet-drop statistics: %s", pcap_geterr(pcap_src->pcap_h)); - report_capture_error(errmsg, please_report); + report_capture_error(errmsg, please_report_bug()); } } report_packet_drops(received, pcap_dropped, pcap_src->dropped, pcap_src->flushed, stats->ps_ifdrop, interface_opts->display_name); @@ -4348,7 +4341,7 @@ capture_loop_get_errmsg(char *errmsg, size_t errmsglen, char *secondary_errmsg, fname, g_strerror(err)); } g_snprintf(secondary_errmsg, (gulong)secondary_errmsglen, - "%s", please_report); + "%s", please_report_bug()); break; } } diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt index 555d99f6a8..030dc9e3ce 100644 --- a/wsutil/CMakeLists.txt +++ b/wsutil/CMakeLists.txt @@ -48,6 +48,7 @@ set(WSUTIL_PUBLIC_HEADERS nstime.h os_version_info.h pint.h + please_report_bug.h plugins.h pow2.h privileges.h @@ -102,6 +103,7 @@ set(WSUTIL_COMMON_FILES nstime.c cpu_info.c os_version_info.c + please_report_bug.c privileges.c rsa.c sober128.c diff --git a/wsutil/please_report_bug.c b/wsutil/please_report_bug.c new file mode 100644 index 0000000000..f05067ac87 --- /dev/null +++ b/wsutil/please_report_bug.c @@ -0,0 +1,33 @@ +/* please_report_bug.c + * Routines returning strings to use when reporting a bug. + * They ask the user to report a bug to the Wireshark developers. + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "please_report_bug.h" + +/* + * Long message, to use in alert boxes and printed messages. + */ +const char * +please_report_bug(void) +{ + return + "Please report this to the Wireshark developers.\n" + "https://bugs.wireshark.org/\n" + "(This is not a crash; please do not report it as such.)"; +} + +/* + * Short message, to use in status bar messages. + */ +const char * +please_report_bug_short(void) +{ + return "Please report this to the Wireshark developers."; +} diff --git a/wsutil/please_report_bug.h b/wsutil/please_report_bug.h new file mode 100644 index 0000000000..508bf5a1a5 --- /dev/null +++ b/wsutil/please_report_bug.h @@ -0,0 +1,35 @@ +/* please_report_bug.h + * Declarations of routines returning strings to use when reporting a bug. + * They ask the user to report a bug to the Wireshark developers. + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef __PLEASE_REPORT_BUG_H__ +#define __PLEASE_REPORT_BUG_H__ + +#include "ws_symbol_export.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Long message, to use in alert boxes and printed messages. + */ +WS_DLL_PUBLIC const char *please_report_bug(void); + +/* + * Short message, to use in status bar messages. + */ +WS_DLL_PUBLIC const char *please_report_bug_short(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __PLEASE_REPORT_BUG_H__ */