summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-06-22 22:54:30 +0200
committerPeter Wu <peter@lekensteyn.nl>2015-06-22 22:54:19 +0000
commit5ab45709d6137175e1f16651f7474876d6d3e758 (patch)
treee2a7172d60e32204fef8062284c1ac103b39f8c7
parent15045316f5dd8e6d59b2617daa370aff925f3c3a (diff)
downloadwireshark-5ab45709d6137175e1f16651f7474876d6d3e758.tar.gz
gtk,qt: Fix minor buffer underrun
Avoid accessing the first byte before an empty dirname. No idea why this was not triggered before. Reproduced with an empty Wireshark profile and wireshark and wireshark-qt. Caught with ASAN. Change-Id: I44f8fdab03ad0f24e663df63a1c54567996a3dfc Reviewed-on: https://code.wireshark.org/review/9037 Reviewed-by: Peter Wu <peter@lekensteyn.nl>
-rw-r--r--ui/gtk/file_dlg.c2
-rw-r--r--ui/qt/wireshark_application.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/ui/gtk/file_dlg.c b/ui/gtk/file_dlg.c
index bb3c2a7752..b7ec47adcb 100644
--- a/ui/gtk/file_dlg.c
+++ b/ui/gtk/file_dlg.c
@@ -448,7 +448,7 @@ set_last_open_dir(const char *dirname)
size_t len;
gchar *new_last_open_dir;
- if (dirname) {
+ if (dirname && dirname[0]) {
len = strlen(dirname);
if (dirname[len-1] == G_DIR_SEPARATOR) {
new_last_open_dir = g_strconcat(dirname, NULL);
diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp
index 7615297a8e..51627c24eb 100644
--- a/ui/qt/wireshark_application.cpp
+++ b/ui/qt/wireshark_application.cpp
@@ -395,7 +395,7 @@ void WiresharkApplication::setLastOpenDir(const char *dir_name)
qint64 len;
gchar *new_last_open_dir;
- if (dir_name) {
+ if (dir_name && dir_name[0]) {
len = strlen(dir_name);
if (dir_name[len-1] == G_DIR_SEPARATOR) {
new_last_open_dir = g_strconcat(dir_name, (char *)NULL);