Fix datatype issue in sscanf() on 64bit systems.
On 64bit systems a 'long' is a 64bit value but the target values of scanf() are always 32bit in the affected code - which means just an 'unsigned int'. Unsigned int is fine on 32 and 64 bit systems. Thanks to Andre Naujoks for reporting this issue.pull/7/head
parent
1463ee4ce4
commit
d3468d907f
11
candump.c
11
candump.c
|
|
@ -443,23 +443,18 @@ int main(int argc, char **argv)
|
||||||
ptr = nptr+1; /* hop behind the ',' */
|
ptr = nptr+1; /* hop behind the ',' */
|
||||||
nptr = strchr(ptr, ','); /* update exit condition */
|
nptr = strchr(ptr, ','); /* update exit condition */
|
||||||
|
|
||||||
if (sscanf(ptr, "%lx:%lx",
|
if (sscanf(ptr, "%x:%x",
|
||||||
(long unsigned int *)
|
|
||||||
&rfilter[numfilter].can_id,
|
&rfilter[numfilter].can_id,
|
||||||
(long unsigned int *)
|
|
||||||
&rfilter[numfilter].can_mask) == 2) {
|
&rfilter[numfilter].can_mask) == 2) {
|
||||||
rfilter[numfilter].can_mask &= ~CAN_ERR_FLAG;
|
rfilter[numfilter].can_mask &= ~CAN_ERR_FLAG;
|
||||||
numfilter++;
|
numfilter++;
|
||||||
} else if (sscanf(ptr, "%lx~%lx",
|
} else if (sscanf(ptr, "%x~%x",
|
||||||
(long unsigned int *)
|
|
||||||
&rfilter[numfilter].can_id,
|
&rfilter[numfilter].can_id,
|
||||||
(long unsigned int *)
|
|
||||||
&rfilter[numfilter].can_mask) == 2) {
|
&rfilter[numfilter].can_mask) == 2) {
|
||||||
rfilter[numfilter].can_id |= CAN_INV_FILTER;
|
rfilter[numfilter].can_id |= CAN_INV_FILTER;
|
||||||
rfilter[numfilter].can_mask &= ~CAN_ERR_FLAG;
|
rfilter[numfilter].can_mask &= ~CAN_ERR_FLAG;
|
||||||
numfilter++;
|
numfilter++;
|
||||||
} else if (sscanf(ptr, "#%lx",
|
} else if (sscanf(ptr, "#%x", &err_mask) != 1) {
|
||||||
(long unsigned int *)&err_mask) != 1) {
|
|
||||||
fprintf(stderr, "Error in filter option parsing: '%s'\n", ptr);
|
fprintf(stderr, "Error in filter option parsing: '%s'\n", ptr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
cangw.c
13
cangw.c
|
|
@ -328,8 +328,7 @@ int parse_mod(char *optarg, struct modattr *modmsg)
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sscanf(++ptr, "%lx.%hhx.%16s",
|
if (sscanf(++ptr, "%x.%hhx.%16s", &modmsg->cf.can_id,
|
||||||
(long unsigned int *)&modmsg->cf.can_id,
|
|
||||||
(unsigned char *)&modmsg->cf.can_dlc, hexdata) != 3)
|
(unsigned char *)&modmsg->cf.can_dlc, hexdata) != 3)
|
||||||
return 5;
|
return 5;
|
||||||
|
|
||||||
|
|
@ -593,13 +592,11 @@ int main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
if (sscanf(optarg, "%lx:%lx",
|
if (sscanf(optarg, "%x:%x", &filter.can_id,
|
||||||
(long unsigned int *)&filter.can_id,
|
&filter.can_mask) == 2) {
|
||||||
(long unsigned int *)&filter.can_mask) == 2) {
|
|
||||||
have_filter = 1;
|
have_filter = 1;
|
||||||
} else if (sscanf(optarg, "%lx~%lx",
|
} else if (sscanf(optarg, "%x~%x", &filter.can_id,
|
||||||
(long unsigned int *)&filter.can_id,
|
&filter.can_mask) == 2) {
|
||||||
(long unsigned int *)&filter.can_mask) == 2) {
|
|
||||||
filter.can_id |= CAN_INV_FILTER;
|
filter.can_id |= CAN_INV_FILTER;
|
||||||
have_filter = 1;
|
have_filter = 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue