Author: pfg
Date: Thu Jan 12 14:44:41 2017
New Revision: 311981
URL: https://svnweb.freebsd.org/changeset/base/311981

Log:
  rpcgen(1): Check getrlimit() return for generated code.
  
  Obtained from:        NetBSD (CVS rev 1.27, 1.28)
  MFC after:    1 week

Modified:
  head/usr.bin/rpcgen/rpc_svcout.c

Modified: head/usr.bin/rpcgen/rpc_svcout.c
==============================================================================
--- head/usr.bin/rpcgen/rpc_svcout.c    Thu Jan 12 14:38:18 2017        
(r311980)
+++ head/usr.bin/rpcgen/rpc_svcout.c    Thu Jan 12 14:44:41 2017        
(r311981)
@@ -728,7 +728,8 @@ write_timeout_func(void)
        if (tirpcflag) {
                f_print(fout, "\t\t\tstruct rlimit rl;\n\n");
                f_print(fout, "\t\t\trl.rlim_max = 0;\n");
-               f_print(fout, "\t\t\tgetrlimit(RLIMIT_NOFILE, &rl);\n");
+               f_print(fout, "\t\t\tif (getrlimit(RLIMIT_NOFILE, &rl) == 
-1)\n");
+               f_print(fout, "\t\t\t\treturn;\n");
                f_print(fout, "\t\t\tif ((size = rl.rlim_max) == 0) {\n");
                
                if (mtflag)
@@ -902,7 +903,11 @@ write_rpc_svc_fg(const char *infile, con
        /* get number of file descriptors */
        if (tirpcflag) {
                f_print(fout, "%srl.rlim_max = 0;\n", sp);
-               f_print(fout, "%sgetrlimit(RLIMIT_NOFILE, &rl);\n", sp);
+               f_print(fout, "%sif (getrlimit(RLIMIT_NOFILE, &rl) == -1) {\n",
+                   sp);
+               f_print(fout, "%s\tperror(\"getrlimit\");\n", sp);
+               f_print(fout, "%s\texit(1);\n", sp);
+               f_print(fout, "%s}\n", sp);
                f_print(fout, "%sif ((size = rl.rlim_max) == 0)\n", sp);
                f_print(fout, "%s\texit(1);\n", sp);
        } else {
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to