From: Victor Julien Date: Tue, 14 May 2024 04:45:30 +0000 (+0200) Subject: device: don't crash on unix command 'iface-bypassed-stat' X-Git-Tag: suricata-7.0.6~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=043efd45bf7ee228f7505db9f7ddd09400e075cd;p=thirdparty%2Fsuricata.git device: don't crash on unix command 'iface-bypassed-stat' In the default config iface bypass support is not enabled, and storage API not initialized for it. Using it will lead to a crash. This commit first checks if the device storage API is initialized. Bug: #7022. (cherry picked from commit bc2dfe4c179774cbd5c70f8f71b759e315a8f0a6) --- diff --git a/src/util-device.c b/src/util-device.c index b624cf0734..82f77a8ce2 100644 --- a/src/util-device.c +++ b/src/util-device.c @@ -584,8 +584,11 @@ void LiveDevAddBypassSuccess(LiveDevice *dev, uint64_t cnt, int family) #ifdef BUILD_UNIX_SOCKET TmEcode LiveDeviceGetBypassedStats(json_t *cmd, json_t *answer, void *data) { + if (g_bypass_storage_id.id < 0) { + json_object_set_new(answer, "message", json_string("Bypass not enabled")); + SCReturnInt(TM_ECODE_FAILED); + } LiveDevice *ldev = NULL, *ndev = NULL; - json_t *ifaces = NULL; while(LiveDeviceForEach(&ldev, &ndev)) { BypassInfo *bpinfo = LiveDevGetStorageById(ldev, g_bypass_storage_id);