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.
This commit is contained in:
Oliver Hartkopp
2010-09-25 10:24:37 +00:00
parent 1463ee4ce4
commit d3468d907f
2 changed files with 8 additions and 16 deletions
+3 -8
View File
@@ -443,23 +443,18 @@ int main(int argc, char **argv)
ptr = nptr+1; /* hop behind the ',' */
nptr = strchr(ptr, ','); /* update exit condition */
if (sscanf(ptr, "%lx:%lx",
(long unsigned int *)
if (sscanf(ptr, "%x:%x",
&rfilter[numfilter].can_id,
(long unsigned int *)
&rfilter[numfilter].can_mask) == 2) {
rfilter[numfilter].can_mask &= ~CAN_ERR_FLAG;
numfilter++;
} else if (sscanf(ptr, "%lx~%lx",
(long unsigned int *)
} else if (sscanf(ptr, "%x~%x",
&rfilter[numfilter].can_id,
(long unsigned int *)
&rfilter[numfilter].can_mask) == 2) {
rfilter[numfilter].can_id |= CAN_INV_FILTER;
rfilter[numfilter].can_mask &= ~CAN_ERR_FLAG;
numfilter++;
} else if (sscanf(ptr, "#%lx",
(long unsigned int *)&err_mask) != 1) {
} else if (sscanf(ptr, "#%x", &err_mask) != 1) {
fprintf(stderr, "Error in filter option parsing: '%s'\n", ptr);
return 1;
}