falcosecurity / libs

libsinsp, libscap, the kernel module driver, and the eBPF driver sources
https://falcosecurity.github.io/libs/
Apache License 2.0
212 stars 159 forks source link

[BUG]: Possible errors in initializing assignment structures #1700

Closed yzewei closed 2 months ago

yzewei commented 4 months ago

Describe the bug

Problems discovered during the compilation of drivers_test https://github.com/falcosecurity/libs/tree/master/test/drivers

[ 19%] Building CXX object test/drivers/CMakeFiles/drivers_test.dir/test_suites/syscall_exit_suite/recvmsg_x.cpp.o
/home/yzw/pr/libs/test/drivers/test_suites/syscall_exit_suite/recvmsg_x.cpp: In member function ‘virtual void SyscallExit_recvmsg_ancillary_data_Test::TestBody()’:
/home/yzw/pr/libs/test/drivers/test_suites/syscall_exit_suite/recvmsg_x.cpp:579:3: error: no match for ‘operator=’ (operand types are ‘msghdr’ and ‘<brace-enclosed initializer list>’)
   };
   ^
cmake -DUSE_BUNDLED_DEPS=On -DENABLE_DRIVERS_TESTS=On -DBUILD_LIBSCAP_GVISOR=Off  -DCREATE_TEST_TARGETS=On ..
make drivers_test

How to reproduce

libs/test/drivers/test_suites/syscall_exit_suite/recvmsg_x.cpp :579

                msg.msg_iov = &iov;
                msg.msg_iovlen = 1;
                msg.msg_control = cmsg_buf;
                msg.msg_controllen = sizeof(cmsg_buf);

                msg_controllen = msg.msg_controllen;
Andreagit97 commented 4 months ago

I cannot reproduce it...can you provide a simple fix? Something like:

        msg.msg_iov = &iov,
        msg.msg_iovlen = 1,
        msg.msg_control = cmsg_buf,
        msg.msg_controllen = sizeof(cmsg_buf)
yzewei commented 4 months ago
                msg.msg_iov = &iov;
                msg.msg_iovlen = 1;
                msg.msg_control = cmsg_buf;
                msg.msg_controllen = sizeof(cmsg_buf);

                msg_controllen = msg.msg_controllen;
yzewei commented 4 months ago

I cannot reproduce it...can you provide a simple fix? Something like:

      msg.msg_iov = &iov,
      msg.msg_iovlen = 1,
      msg.msg_control = cmsg_buf,
      msg.msg_controllen = sizeof(cmsg_buf)

like this? https://github.com/falcosecurity/libs/issues/1700#issuecomment-1965893916

Andreagit97 commented 4 months ago

yes!

FedeDP commented 2 months ago

I think this should have been fixed by: https://github.com/falcosecurity/libs/commit/83f152905b5ed714d044d2badf40f335ad7eeb39 (part of https://github.com/falcosecurity/libs/pull/1731)