From 134d7b1ef94ae6f4f6ffb58b17fcd2643c6ae9ac Mon Sep 17 00:00:00 2001 From: dv Date: Mon, 22 Jul 2024 17:55:18 +0000 Subject: [PATCH] rpcgen(1): default to "STDIN" as input file when compiling to headers. FreeBSD, NetBSD, and GNU all use a variation of "STDIN" as the default input filename when compiling to header files (-h) to prevent a NULL-pointer deference. Adopt a similar approach. ok millert@ --- usr.bin/rpcgen/rpc_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c index 3d04fdc7f9e..ef82a734429 100644 --- a/usr.bin/rpcgen/rpc_main.c +++ b/usr.bin/rpcgen/rpc_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rpc_main.c,v 1.35 2019/06/28 13:35:03 deraadt Exp $ */ +/* $OpenBSD: rpc_main.c,v 1.36 2024/07/22 17:55:18 dv Exp $ */ /* $NetBSD: rpc_main.c,v 1.9 1996/02/19 11:12:43 pk Exp $ */ /* @@ -480,7 +480,10 @@ h_output(infile, define, extend, outfile) outfilename = extend ? extendfile(infile, outfile) : outfile; open_output(infile, outfilename); add_warning(); - guard = generate_guard(outfilename ? outfilename : infile); + if (outfilename || infile) + guard = generate_guard(outfilename ? outfilename : infile); + else + guard = generate_guard("STDIN"); fprintf(fout, "#ifndef _%s\n#define _%s\n\n", guard, guard); -- 2.20.1