sysctl.c (29583dfcd2dd72c766422bd05c16f06c6b1fb356) | sysctl.c (e6cfaf34be9fcd1a8285a294e18986bfc41a409c) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * sysctl.c: General linux system control interface 4 * 5 * Begun 24 March 1995, Stephen Tweedie 6 * Added /proc support, Dec 1995 7 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas. 8 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver. --- 328 unchanged lines hidden (view full) --- 337 * the amount of bytes read. If @tr is non-NULL and a trailing 338 * character exists (size is non-zero after returning from this 339 * function), @tr is updated with the trailing character. 340 */ 341static int proc_get_long(char **buf, size_t *size, 342 unsigned long *val, bool *neg, 343 const char *perm_tr, unsigned perm_tr_len, char *tr) 344{ | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * sysctl.c: General linux system control interface 4 * 5 * Begun 24 March 1995, Stephen Tweedie 6 * Added /proc support, Dec 1995 7 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas. 8 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver. --- 328 unchanged lines hidden (view full) --- 337 * the amount of bytes read. If @tr is non-NULL and a trailing 338 * character exists (size is non-zero after returning from this 339 * function), @tr is updated with the trailing character. 340 */ 341static int proc_get_long(char **buf, size_t *size, 342 unsigned long *val, bool *neg, 343 const char *perm_tr, unsigned perm_tr_len, char *tr) 344{ |
345 int len; | |
346 char *p, tmp[TMPBUFLEN]; | 345 char *p, tmp[TMPBUFLEN]; |
346 ssize_t len = *size; |
|
347 | 347 |
348 if (!*size) | 348 if (len <= 0) |
349 return -EINVAL; 350 | 349 return -EINVAL; 350 |
351 len = *size; | |
352 if (len > TMPBUFLEN - 1) 353 len = TMPBUFLEN - 1; 354 355 memcpy(tmp, *buf, len); 356 357 tmp[len] = 0; 358 p = tmp; 359 if (*p == '-' && *size > 1) { --- 2157 unchanged lines hidden --- | 351 if (len > TMPBUFLEN - 1) 352 len = TMPBUFLEN - 1; 353 354 memcpy(tmp, *buf, len); 355 356 tmp[len] = 0; 357 p = tmp; 358 if (*p == '-' && *size > 1) { --- 2157 unchanged lines hidden --- |