Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Jan 2017 14:44:42 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r311981 - head/usr.bin/rpcgen
Message-ID:  <201701121444.v0CEigj8008356@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701121444.v0CEigj8008356>