-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
daemon: check payload length before cast to struct #3
daemon: check payload length before cast to struct #3
Conversation
Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
The fix looks good to me, but too much repetition for my taste. I understand there is repetition in the original code, but this just extends it. Every function (except one) seems to do the same checks and very similar error reporting. Refactor? |
What do you think about doing the check inside a define and just call it later to reduce the duplication: /* checks if received size is big enough for expected data. */ |
Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com> Improve macro after review Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
Sorry for late response. Yes I was thinking something like that exactly, but:
**Rather than complain about your bugfix :-) good practice is to do one thing at a time so I'd still propose we take your bugfix in one commit, and then refactor in the next commit. Do you need the bugfix urgently? In that case we should recommend mering your fix in first. Let me take a deeper look. Maybe I'll make a proposal based on top of your bugfix if you don't mind - taking the opportunity to do some programming for a change :-) |
Hi, |
Adding refs to email discussions. |
Well here's a +1 from me at least, but @GeniviDLTmaintainer should weigh in I guess (or is that you nowadays ;-) +1 because I figure we could refactor and align error management after this merge |
Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
now you can do make test after make :) === Sample build and test: $ cmake -Bbuild -H. \ -DDLT_IPC=UNIX_SOCKET \ -DWITH_DLT_ADAPTOR=ON \ -DWITH_DLT_UNIT_TESTS=ON \ -DWITH_DLT_CXX11_EXT=ON \ -DWITH_DLT_MONITOR=OFF \ -DWITH_DLT_USE_IPv6=OFF $ cd build $ make $ make test Running tests... Test project /home/fherrmann/git/dlt-daemon/build Start 1: gtest_dlt_common 1/5 Test #1: gtest_dlt_common ................. Passed 0.02 sec Start 2: gtest_dlt_user 2/5 Test #2: gtest_dlt_user ................... Passed 1.01 sec Start 3: gtest_dlt_daemon_common 3/5 Test #3: gtest_dlt_daemon_common .......... Passed 0.01 sec Start 4: dlt_env_ll_unit_test 4/5 Test #4: dlt_env_ll_unit_test ............. Passed 0.04 sec Start 5: gtest_dlt_daemon_event_handler 5/5 Test #5: gtest_dlt_daemon_event_handler ... Passed 1.01 sec 100% tests passed, 0 tests failed out of 5 Total Test time (real) = 2.09 sec === Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
Check if size of control request structure fits into actual payload datasize. In case it does not fit, return with error message.