isotpsniffer: only invoke LL_OPTS setsockopt when set on commandline
In commitpull/102/merge v2020.02.04da33f96edf("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>
parent
ae69062657
commit
da65fdfe0d
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue