]> git.ipfire.org Git - thirdparty/suricata.git/commit
af-packet/v2: use proper type for ring
authorVictor Julien <vjulien@oisf.net>
Wed, 27 Apr 2022 09:32:22 +0000 (11:32 +0200)
committerVictor Julien <vjulien@oisf.net>
Tue, 3 May 2022 11:30:20 +0000 (13:30 +0200)
commitbd60eb1f44863a1f028f8824b9b3f2fd46443d5a
tree47577ef05b6ec50af14422a79cdaf15138c2c614
parentf2e30e602c50219c4d5d4683f53a246e5929aa97
af-packet/v2: use proper type for ring

cppcheck:

src/source-af-packet.c:1762:19: warning: Size of pointer 'v2' used instead of size of its data. This is likely to lead to a buffer overflow. You probably intend to write 'sizeof(*v2)'. [pointerSize]
        ptv->ring.v2 = SCMalloc(ptv->req.v2.tp_frame_nr * sizeof (union thdr *));
                  ^
src/source-af-packet.c:1767:26: warning: Size of pointer 'v2' used instead of size of its data. This is likely to lead to a buffer overflow. You probably intend to write 'sizeof(*v2)'. [pointerSize]
        memset(ptv->ring.v2, 0, ptv->req.v2.tp_frame_nr * sizeof (union thdr *));
                         ^

scan-build:

CC       source-af-packet.o
source-af-packet.c:1762:24: warning: Result of 'malloc' is converted to a pointer of type 'char', which is incompatible with sizeof operand type 'union thdr *' [unix.MallocSizeof]
        ptv->ring.v2 = SCMalloc(ptv->req.v2.tp_frame_nr * sizeof (union thdr *));
                       ^~~~~~~~                           ~~~~~~~~~~~~~~~~~~~~~
./util-mem.h:35:18: note: expanded from macro 'SCMalloc'
                 ^~~~~~
1 warning generated.

Bug: #5291.
(cherry picked from commit fedced209dc25443ec5eee22bfab6c99f9f652ab)
src/source-af-packet.c