Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/ksh CID 1225088: check return of getrlimit



details:   https://anonhg.NetBSD.org/src/rev/74f54fc5c217
branches:  trunk
changeset: 338045:74f54fc5c217
user:      christos <christos%NetBSD.org@localhost>
date:      Sat May 09 13:26:06 2015 +0000

description:
CID 1225088: check return of getrlimit

diffstat:

 bin/ksh/c_ulimit.c |  18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

diffs (46 lines):

diff -r c3067715f571 -r 74f54fc5c217 bin/ksh/c_ulimit.c
--- a/bin/ksh/c_ulimit.c        Sat May 09 13:22:37 2015 +0000
+++ b/bin/ksh/c_ulimit.c        Sat May 09 13:26:06 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: c_ulimit.c,v 1.11 2015/05/09 13:22:37 christos Exp $   */
+/*     $NetBSD: c_ulimit.c,v 1.12 2015/05/09 13:26:06 christos Exp $   */
 
 /*
        ulimit -- handle "ulimit" builtin
@@ -20,7 +20,7 @@
 #include <sys/cdefs.h>
 
 #ifndef lint
-__RCSID("$NetBSD: c_ulimit.c,v 1.11 2015/05/09 13:22:37 christos Exp $");
+__RCSID("$NetBSD: c_ulimit.c,v 1.12 2015/05/09 13:26:06 christos Exp $");
 #endif
 
 
@@ -203,9 +203,12 @@
                for (l = limits; l->name; l++) {
 #ifdef HAVE_SETRLIMIT
                        if (l->which == RLIMIT) {
-                               if (getrlimit(l->gcmd, &limit) == -1)
-                                       val = RLIM_INFINITY;
-                               else if (how & SOFT)
+                               if (getrlimit(l->gcmd, &limit) == -1) {
+                                       bi_errorf("can't get limit: %s",
+                                           strerror(errno));
+                                       return 1;
+                               }
+                               if (how & SOFT)
                                        val = limit.rlim_cur;
                                else if (how & HARD)
                                        val = limit.rlim_max;
@@ -233,7 +236,10 @@
        }
 #ifdef HAVE_SETRLIMIT
        if (l->which == RLIMIT) {
-               getrlimit(l->gcmd, &limit);
+               if (getrlimit(l->gcmd, &limit) == -1) {
+                       bi_errorf("can't get limit: %s", strerror(errno));
+                       return 1;
+               }
                if (set) {
                        if (how & SOFT)
                                limit.rlim_cur = val;



Home | Main Index | Thread Index | Old Index