New upstream version 4.15.2
This commit is contained in:
+14
-10
@@ -29,7 +29,11 @@
|
||||
#include "getdef.h"
|
||||
#include "shadowlog.h"
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include "atoi/str2i.h"
|
||||
#include "memzero.h"
|
||||
|
||||
|
||||
#ifndef LIMITS_FILE
|
||||
#define LIMITS_FILE "/etc/limits"
|
||||
#endif
|
||||
@@ -45,7 +49,7 @@ static int setrlimit_value (unsigned int resource,
|
||||
const char *value,
|
||||
unsigned int multiplier)
|
||||
{
|
||||
char *endptr;
|
||||
char *end;
|
||||
long l;
|
||||
rlim_t limit;
|
||||
struct rlimit rlim;
|
||||
@@ -57,15 +61,15 @@ static int setrlimit_value (unsigned int resource,
|
||||
limit = RLIM_INFINITY;
|
||||
}
|
||||
else {
|
||||
/* We cannot use getlong here because it fails when there
|
||||
/* We cannot use str2sl() here because it fails when there
|
||||
* is more to the value than just this number!
|
||||
* Also, we are limited to base 10 here (hex numbers will not
|
||||
* work with the limit string parser as is anyway)
|
||||
*/
|
||||
errno = 0;
|
||||
l = strtol(value, &endptr, 10);
|
||||
l = strtol(value, &end, 10);
|
||||
|
||||
if (value == endptr || errno != 0)
|
||||
if (value == end || errno != 0)
|
||||
return 0; // FIXME: We could instead throw an error, though.
|
||||
|
||||
if (__builtin_mul_overflow(l, multiplier, &limit)) {
|
||||
@@ -89,7 +93,7 @@ static int set_prio (const char *value)
|
||||
{
|
||||
long prio;
|
||||
|
||||
if ( (getlong(value, &prio) == -1)
|
||||
if ( (str2sl(&prio, value) == -1)
|
||||
|| (prio != (int) prio)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -104,7 +108,7 @@ static int set_umask (const char *value)
|
||||
{
|
||||
unsigned long mask;
|
||||
|
||||
if ( (getulong(value, &mask) == -1)
|
||||
if ( (str2ul(&mask, value) == -1)
|
||||
|| (mask != (mode_t) mask)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -119,7 +123,7 @@ static int check_logins (const char *name, const char *maxlogins)
|
||||
{
|
||||
unsigned long limit, count;
|
||||
|
||||
if (getulong(maxlogins, &limit) == -1) {
|
||||
if (str2ul(&limit, maxlogins) == -1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -482,7 +486,7 @@ void setup_limits (const struct passwd *info)
|
||||
if (strncmp (cp, "pri=", 4) == 0) {
|
||||
long inc;
|
||||
|
||||
if ( (getlong(cp + 4, &inc) == 0)
|
||||
if ( (str2sl(&inc, cp + 4) == 0)
|
||||
&& (inc >= -20) && (inc <= 20)) {
|
||||
errno = 0;
|
||||
if ( (nice (inc) != -1)
|
||||
@@ -500,7 +504,7 @@ void setup_limits (const struct passwd *info)
|
||||
}
|
||||
if (strncmp (cp, "ulimit=", 7) == 0) {
|
||||
long blocks;
|
||||
if ( (getlong(cp + 7, &blocks) == -1)
|
||||
if ( (str2sl(&blocks, cp + 7) == -1)
|
||||
|| (blocks != (int) blocks)
|
||||
|| (set_filesize_limit (blocks) != 0)) {
|
||||
SYSLOG ((LOG_WARN,
|
||||
@@ -512,7 +516,7 @@ void setup_limits (const struct passwd *info)
|
||||
if (strncmp (cp, "umask=", 6) == 0) {
|
||||
unsigned long mask;
|
||||
|
||||
if ( (getulong(cp + 6, &mask) == -1)
|
||||
if ( (str2ul(&mask, cp + 6) == -1)
|
||||
|| (mask != (mode_t) mask)) {
|
||||
SYSLOG ((LOG_WARN,
|
||||
"Can't set umask value for user %s",
|
||||
|
||||
Reference in New Issue
Block a user