this repo has no description
1
fork

Configure Feed

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

renaming counter and changing space adding

+28 -10
+28 -10
src/kernel/emulation/linux/misc/sysctl_machdep.c
··· 3 3 #include <sys/errno.h> 4 4 #include <alloca.h> 5 5 6 - extern char *strcpy(char *dest, const char *src); 6 + extern char *strncpy(char *dest, const char *src); 7 7 8 8 enum { 9 9 _MACHDEP_CPU = 1000, ··· 179 179 180 180 return 0; 181 181 } 182 + 182 183 sysctl_handler(handle_features) 183 184 { 184 185 ··· 193 194 if(old != NULL) 194 195 { 195 196 196 - int counter = 0; 197 + char *outsr = (char*)old; 198 + int current_length = 0; 197 199 int j = 0; 198 200 199 201 for (int i = 0; i < 32; i++) ··· 202 204 if(i == 10 || i == 20) 203 205 continue; 204 206 205 - if(edx>>i&1 && counter < *oldlen) 207 + if(edx>>i&1 && current_length < *oldlen) 206 208 { 207 - int len = __simple_strlen(features[i]); 208 - 209 - strncpy(old,features[i]); 210 209 211 - counter = counter + len; 210 + if (current_length) 211 + { 212 + 213 + outsr[current_length] = ' '; 214 + 215 + current_length++; 216 + 217 + } 212 218 213 - if(counter < *oldlen) 219 + if(current_length < *oldlen) 214 220 { 215 221 216 - old[counter] = ' '; 222 + int len = __simple_strlen(features[i]); 223 + 224 + strncpy(outsr + current_length, features[i], 225 + (len < (*oldlen - current_length) ? len : (*oldlen - current_length))); 217 226 218 - counter++; 227 + current_length = current_length + len; 219 228 220 229 } 221 230 222 231 } 232 + 223 233 } 234 + 235 + if(current_length < *oldlen) 236 + { 237 + 238 + outsr[current_length] = '\0'; 239 + 240 + } 241 + 224 242 } 225 243 else 226 244 {