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 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.

--apb (Alan Barrett)


Home | Main Index | Thread Index | Old Index