this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix pointer to long long being passed has garbage

Before, we were treating it as an int pointer. On x86_64, that is 4
bytes. If a long pointer that hasn't been zeroed out was passed into
sysctl then it may have garbage in the 4 higher order bytes if an int
is copied into it.

+17 -2
+17 -2
src/kernel/emulation/linux/misc/sysctl_hw.c
··· 105 105 106 106 sysctl_handler(handle_memsize) 107 107 { 108 + 108 109 sysctl_handle_size(sizeof(unsigned long long)); 109 110 *((unsigned long long*) old) = gethostinfo()->max_mem; 110 111 return 0; ··· 112 113 113 114 sysctl_handler(handle_pagesize) 114 115 { 115 - sysctl_handle_size(sizeof(int)); 116 - *((int*) old) = 4096; // true on all Darling platforms 116 + //sysctl_handle_size(sizeof(int)); 117 + // TODO: maybe should be int64_t (long long) all the time, keeping compatability with int for now 118 + if (old == NULL) 119 + { 120 + *oldlen = sizeof(int); 121 + return 0; 122 + } 123 + else if (*oldlen == sizeof(long long)) 124 + { 125 + *((long long*) old) = 4096; // true on all Darling platforms 126 + } 127 + else 128 + { 129 + *((int*) old) = 4096; // true on all Darling platforms 130 + *oldlen = sizeof(int); 131 + } 117 132 return 0; 118 133 } 119 134