mirror of
https://github.com/linux-can/can-utils.git
synced 2026-08-05 14:29:54 +02:00
isotpsniffer: only invoke LL_OPTS setsockopt when set on commandline
In commitda33f96edf("isotpsniffer: Add support for llopts") the setsockopt() syscall for the link layer options CAN_ISOTP_LL_OPTS has been added. Unfortunately the syscall has been invoked even if there were no values given on the command line and 'zero values' have been passed to the kernel which correctly answered with -EINVAL. And a missing check for a mandatory non-zero value for the MTU. Fixes:da33f96edf("isotpsniffer: Add support for llopts") Reported by: https://github.com/ikuyas Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
This commit is contained in:
+1
-1
@@ -322,7 +322,7 @@ int main(int argc, char **argv)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((setsockopt(t, SOL_CAN_ISOTP, CAN_ISOTP_LL_OPTS, &llopts, sizeof(llopts))) < 0) {
|
||||
if ((llopts.mtu) && (setsockopt(t, SOL_CAN_ISOTP, CAN_ISOTP_LL_OPTS, &llopts, sizeof(llopts))) < 0) {
|
||||
perror("setsockopt");
|
||||
r = 1;
|
||||
goto out;
|
||||
|
||||
Reference in New Issue
Block a user