Thread (6 messages) flat view 6 messages, 4 authors, 2009-10-30

Re: [PATCH] ax25: unsigned cannot be less than 0 in ax25_ctl_ioctl()

From: Kevin Dawson <hidden>
Date: 2009-10-12 22:24:32
Also in: linux-hams

Possibly related (same subject, not in this thread)

Roel Kluin wrote:
quoted
 tmp_arg=ax25_ctl.arg * HZ;

  if (arg == 0 || arg >  ULONG_MAX )
		goto einval_put;
I'm not sure, I think this would only work if we made `arg' an
unsigned long long.
That depends on the possible values of ax25_ctl.arg.
+	if (ax25_ctl.arg * HZ > ULONG_MAX && ax25_ctl.cmd != AX25_KILL)
+		return -EINVAL;
Why the need to change arg before comparing it with a constant?  Let the 
compiler do the work:

	if (ax25_ctl.arg > ULONG_MAX / HZ && ...

Kevin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help