mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
nwfilter: use time_t for timeout for consistency
Coverity scan reports: "A time_t value is stored in an integer with too few bits to accommodate it. The expression timeout is cast to unsigned int" We are already casting and storing time_t timeout variable into unsigned int. We can use time_t for timeout and cast it to unsigned long (should be big enough) instead of unsigned int in sscanf, g_strdup_printf as required. Signed-off-by: Shaleen Bathla <shaleen.bathla@oracle.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
d45ee63b90
commit
0d278aa089
@ -146,7 +146,7 @@ struct _virNWFilterSnoopIPLease {
|
||||
virSocketAddr ipAddress;
|
||||
virSocketAddr ipServer;
|
||||
virNWFilterSnoopReq * snoopReq;
|
||||
unsigned int timeout;
|
||||
time_t timeout;
|
||||
/* timer list */
|
||||
virNWFilterSnoopIPLease *prev;
|
||||
virNWFilterSnoopIPLease *next;
|
||||
@ -1580,7 +1580,9 @@ virNWFilterSnoopLeaseFileWrite(int lfd, const char *ifkey,
|
||||
return -1;
|
||||
|
||||
/* time intf ip dhcpserver */
|
||||
lbuf = g_strdup_printf("%u %s %s %s\n", ipl->timeout, ifkey, ipstr, dhcpstr);
|
||||
lbuf = g_strdup_printf("%llu %s %s %s\n",
|
||||
(unsigned long long) ipl->timeout,
|
||||
ifkey, ipstr, dhcpstr);
|
||||
len = strlen(lbuf);
|
||||
|
||||
if (safewrite(lfd, lbuf, len) != len) {
|
||||
@ -1739,7 +1741,8 @@ virNWFilterSnoopLeaseFileLoad(void)
|
||||
}
|
||||
ln++;
|
||||
/* key len 54 = "VMUUID"+'-'+"MAC" */
|
||||
if (sscanf(line, "%u %54s %15s %15s", &ipl.timeout,
|
||||
if (sscanf(line, "%llu %54s %15s %15s",
|
||||
(unsigned long long *) &ipl.timeout,
|
||||
ifkey, ipstr, srvstr) < 4) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("virNWFilterSnoopLeaseFileLoad lease file "
|
||||
|
Loading…
Reference in New Issue
Block a user