Module Name:    src
Committed By:   tnn
Date:           Mon Aug  7 21:12:02 UTC 2023

Modified Files:
        src/usr.bin/rpcgen: rpc_cout.c

Log Message:
rpcgen: don't pass length of source to string copy operation

Altough the prior code can't fail, GCC complains about the practice.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/rpcgen/rpc_cout.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/rpcgen/rpc_cout.c
diff -u src/usr.bin/rpcgen/rpc_cout.c:1.38 src/usr.bin/rpcgen/rpc_cout.c:1.39
--- src/usr.bin/rpcgen/rpc_cout.c:1.38	Sat Jan 23 02:33:09 2016
+++ src/usr.bin/rpcgen/rpc_cout.c	Mon Aug  7 21:12:02 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: rpc_cout.c,v 1.38 2016/01/23 02:33:09 dholland Exp $	*/
+/*	$NetBSD: rpc_cout.c,v 1.39 2023/08/07 21:12:02 tnn Exp $	*/
 /*
  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  * unrestricted use provided that this legend is included on all tape
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)rpc_cout.c 1.13 89/02/22 (C) 1987 SMI";
 #else
-__RCSID("$NetBSD: rpc_cout.c,v 1.38 2016/01/23 02:33:09 dholland Exp $");
+__RCSID("$NetBSD: rpc_cout.c,v 1.39 2023/08/07 21:12:02 tnn Exp $");
 #endif
 #endif
 
@@ -186,7 +186,9 @@ print_ifopen(int indent, const char *nam
 	if (!strcmp(name, "rpcprog_t") || !strcmp(name, "rpcvers_t") ||
 	    !strcmp(name, "rpcproc_t") || !strcmp(name, "rpcprot_t") ||
 	    !strcmp(name, "rpcport_t") || !strcmp(name, "rpcpinline_t")) {
-		strncpy(_t_kludge, name, strlen(name) - 2);
+		strlcpy(_t_kludge, name, sizeof(_t_kludge));
+		char *underscore = strchr(_t_kludge, '_');
+		*underscore = 0;
 		name = _t_kludge;
 	}
 	tabify(fout, indent);

Reply via email to