Module Name:    src
Committed By:   snj
Date:           Mon Feb 19 19:45:23 UTC 2018

Modified Files:
        src/usr.sbin/ypserv/ypserv [netbsd-7]: ypserv_proc.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #1566):
        usr.sbin/ypserv/ypserv/ypserv_proc.c: 1.18
PR/47615: Dr. W. Stukenbrock: Always zero out the result structs in the
svc procs to avoid returning stale request data to the client.


To generate a diff of this commit:
cvs rdiff -u -r1.16.20.1 -r1.16.20.2 src/usr.sbin/ypserv/ypserv/ypserv_proc.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.sbin/ypserv/ypserv/ypserv_proc.c
diff -u src/usr.sbin/ypserv/ypserv/ypserv_proc.c:1.16.20.1 src/usr.sbin/ypserv/ypserv/ypserv_proc.c:1.16.20.2
--- src/usr.sbin/ypserv/ypserv/ypserv_proc.c:1.16.20.1	Fri Jul 31 17:06:56 2015
+++ src/usr.sbin/ypserv/ypserv/ypserv_proc.c	Mon Feb 19 19:45:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ypserv_proc.c,v 1.16.20.1 2015/07/31 17:06:56 snj Exp $	*/
+/*	$NetBSD: ypserv_proc.c,v 1.16.20.2 2018/02/19 19:45:23 snj Exp $	*/
 
 /*
  * Copyright (c) 1994 Mats O Jansson <m...@stacken.kth.se>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ypserv_proc.c,v 1.16.20.1 2015/07/31 17:06:56 snj Exp $");
+__RCSID("$NetBSD: ypserv_proc.c,v 1.16.20.2 2018/02/19 19:45:23 snj Exp $");
 #endif
 
 #include <sys/stat.h>
@@ -163,9 +163,10 @@ ypproc_match_2_svc(void *argp, struct sv
 	    "key %.*s", clientstr, TORF(secure), k->domain, k->map,
 	    k->keydat.dsize, k->keydat.dptr));
 
-	if (secure && securecheck(caller))
+	if (secure && securecheck(caller)) {
+		memset(&res, 0, sizeof(res));
 		res.status = YP_YPERR;
-	else
+	} else
 		res = ypdb_get_record(k->domain, k->map, k->keydat, secure);
 
 	return ((void *)&res);
@@ -190,9 +191,10 @@ ypproc_first_2_svc(void *argp, struct sv
 	    "first_2: request from %.500s, secure %s, domain %s, map %s",
 	    clientstr, TORF(secure), k->domain, k->map));
 
-	if (secure && securecheck(caller))
+	if (secure && securecheck(caller)) {
+		memset(&res, 0, sizeof(res));
 		res.status = YP_YPERR;
-	else
+	} else
 		res = ypdb_get_first(k->domain, k->map, FALSE);
 
 	return ((void *)&res);
@@ -218,9 +220,10 @@ ypproc_next_2_svc(void *argp, struct svc
 	    "key %.*s", clientstr, TORF(secure), k->domain, k->map,
 	    k->keydat.dsize, k->keydat.dptr));
 
-	if (secure && securecheck(caller))
+	if (secure && securecheck(caller)) {
+		memset(&res, 0, sizeof(res));
 		res.status = YP_YPERR;
-	else
+	} else
 		res = ypdb_get_next(k->domain, k->map, k->keydat, FALSE);
 
 	return ((void *)&res);
@@ -326,6 +329,7 @@ ypproc_all_2_svc(void *argp, struct svc_
 	(void)memset(&res, 0, sizeof(res));
 
 	if (secure && securecheck(caller)) {
+		memset(&res, 0, sizeof(res));
 		res.ypresp_all_u.val.status = YP_YPERR;
 		return (&res);
 	}
@@ -368,9 +372,10 @@ ypproc_master_2_svc(void *argp, struct s
 	    "master_2: request from %.500s, secure %s, domain %s, map %s",
 	    clientstr, TORF(secure), k->domain, k->map));
 
-	if (secure && securecheck(caller))
+	if (secure && securecheck(caller)) {
+		memset(&res, 0, sizeof(res));
 		res.status = YP_YPERR;
-	else
+	} else
 		res = ypdb_get_master(k->domain, k->map);
 
 	/*
@@ -409,12 +414,15 @@ ypproc_order_2_svc(void *argp, struct sv
 	    "order_2: request from %.500s, secure %s, domain %s, map %s",
 	    clientstr, TORF(secure), k->domain, k->map));
 
-	if (secure && securecheck(caller))
+	if (secure && securecheck(caller)) {
+		memset(&res, 0, sizeof(res));
 		res.status = YP_YPERR;
-	else if (_yp_invalid_map(k->map))
+	} else if (_yp_invalid_map(k->map)) {
+		memset(&res, 0, sizeof(res));
 		res.status = YP_NOMAP;
-	else
+	} else {
 		res = ypdb_get_order(k->domain, k->map);
+	}
 
 	return ((void *)&res);
 }
@@ -446,7 +454,7 @@ ypproc_maplist_2_svc(void *argp, struct 
 	(void)snprintf(domain_path, sizeof(domain_path), "%s/%s", YP_DB_PATH,
 	    domain);
 
-	res.list = NULL;
+	memset(&res, 0, sizeof(res));
 	status = YP_TRUE;
 
 	if ((stat(domain_path, &finfo) != 0) || !S_ISDIR(finfo.st_mode)) {

Reply via email to