mirror of
https://github.com/opnsense/src.git
synced 2026-06-03 13:58:30 -04:00
login_cap.c: Don't set errno to ERANGE on memory allocation failure
Modified functions: login_getcaptime(), login_getcapnum(), login_getcapsize(). They all call cgetstr(), which returns -2 on such conditions and already sets errno to ENOMEM, arguably the appropriate value for these functions as well. No in-tree consumer currently checks for errno on error reported by these functions, so this change has no other code impact. Reviewed by: kib MFC after: 2 weeks Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40342 (cherry picked from commit b8c1aadef9d80786daf731300c33d3a001261422)
This commit is contained in:
parent
74e9205b5e
commit
83bcaf3b2d
1 changed files with 8 additions and 13 deletions
|
|
@ -650,10 +650,8 @@ login_getcaptime(login_cap_t *lc, const char *cap, rlim_t def, rlim_t error)
|
|||
|
||||
if ((r = cgetstr(lc->lc_cap, cap, &res)) == -1)
|
||||
return def;
|
||||
else if (r < 0) {
|
||||
errno = ERANGE;
|
||||
else if (r < 0)
|
||||
return error;
|
||||
}
|
||||
|
||||
/* "inf" and "infinity" are special cases */
|
||||
if (isinfinite(res))
|
||||
|
|
@ -735,19 +733,18 @@ login_getcapnum(login_cap_t *lc, const char *cap, rlim_t def, rlim_t error)
|
|||
/*
|
||||
* For BSDI compatibility, try for the tag=<val> first
|
||||
*/
|
||||
if ((r = cgetstr(lc->lc_cap, cap, &res)) == -1) {
|
||||
r = cgetstr(lc->lc_cap, cap, &res);
|
||||
if (r == -1) {
|
||||
long lval;
|
||||
/* string capability not present, so try for tag#<val> as numeric */
|
||||
if ((r = cgetnum(lc->lc_cap, cap, &lval)) == -1)
|
||||
return def; /* Not there, so return default */
|
||||
else if (r >= 0)
|
||||
else if (r < 0)
|
||||
return error;
|
||||
else
|
||||
return (rlim_t)lval;
|
||||
}
|
||||
|
||||
if (r < 0) {
|
||||
errno = ERANGE;
|
||||
} else if (r < 0)
|
||||
return error;
|
||||
}
|
||||
|
||||
if (isinfinite(res))
|
||||
return RLIM_INFINITY;
|
||||
|
|
@ -786,10 +783,8 @@ login_getcapsize(login_cap_t *lc, const char *cap, rlim_t def, rlim_t error)
|
|||
|
||||
if ((r = cgetstr(lc->lc_cap, cap, &res)) == -1)
|
||||
return def;
|
||||
else if (r < 0) {
|
||||
errno = ERANGE;
|
||||
else if (r < 0)
|
||||
return error;
|
||||
}
|
||||
|
||||
if (isinfinite(res))
|
||||
return RLIM_INFINITY;
|
||||
|
|
|
|||
Loading…
Reference in a new issue