Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/kern



On Sat, Mar 01, 2014 at 08:31:42AM +0200, Alan Barrett wrote:
> On Thu, 27 Feb 2014, David Laight wrote:
> >Modified Files:
> >     src/sys/kern: kern_sysctl.c
> 
> >+    case CTLTYPE_INT:
> >+            /* Allow for 64bit read of 32bit value */
> >+            if (*oldlenp == sizeof (uint64_t)) {
> >+                    qval = *(int *)d;
> >+                    d_out = &qval;
> >+                    sz =  sizeof (uint64_t);
> >+            }
> >+            break;
> >+    case CTLTYPE_QUAD:
> >+            /* Allow for 32bit read of 64bit value */
> >+            if (*oldlenp == sizeof (int)) {
> >+                    qval = *(uint64_t *)d;
> >+                    ival = qval < 0x100000000 ? qval : 0xffffffff;
> >+                    d_out = &ival;
> >+                    sz =  sizeof (int);
> >+            }
> >+            break;
> 
> This will fail if int is not a 32-bit type, because it uses hardcoded
> masks instead of adapting to the actual size.

It goes wrong if 'int' is larger than 'uint64_t' as well!
I'll fix it for 64bit int (modulo any signed v unsigned warnings).

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index