device: limit device id to uint16_t

Meaning that we support 65535 live devices at the most
pull/8965/head
Philippe Antoine 4 years ago committed by Victor Julien
parent a4ade056cc
commit 92884b9f43

@ -132,6 +132,12 @@ int LiveRegisterDevice(const char *dev)
return -1;
}
int id = LiveGetDeviceCount();
if (id > UINT16_MAX) {
SCFree(pd);
return -1;
}
pd->dev = SCStrdup(dev);
if (unlikely(pd->dev == NULL)) {
SCFree(pd);
@ -143,7 +149,7 @@ int LiveRegisterDevice(const char *dev)
SC_ATOMIC_INIT(pd->pkts);
SC_ATOMIC_INIT(pd->drop);
SC_ATOMIC_INIT(pd->invalid_checksums);
pd->id = LiveGetDeviceCount();
pd->id = (uint16_t)id;
TAILQ_INSERT_TAIL(&live_devices, pd, next);
SCLogDebug("Device \"%s\" registered and created.", dev);

@ -51,7 +51,7 @@ typedef struct LiveDevice_ {
char dev_short[MAX_DEVNAME + 1];
bool tenant_id_set;
int id;
uint16_t id;
SC_ATOMIC_DECLARE(uint64_t, pkts);
SC_ATOMIC_DECLARE(uint64_t, drop);

Loading…
Cancel
Save