$NetBSD: patch-ao,v 1.1 2006/08/09 17:58:09 salo Exp $

Security fix for SA21436.

--- appl/rcp/rcp.c.orig	2005-05-11 13:04:30.000000000 +0200
+++ appl/rcp/rcp.c	2006-08-09 19:42:15.000000000 +0200
@@ -119,13 +119,15 @@ main(int argc, char **argv)
 
 	if (fflag) {			/* Follow "protocol", send data. */
 		response();
-		setuid(userid);
+		if (setuid(userid) < 0)
+			errx(1, "setuid failed");
 		source(argc, argv);
 		exit(errs);
 	}
 
 	if (tflag) {			/* Receive data. */
-		setuid(userid);
+		if (setuid(userid) < 0)
+			errx(1, "setuid failed");
 		sink(argc, argv);
 		exit(errs);
 	}
@@ -221,7 +223,8 @@ toremote(char *targ, int argc, char **ar
 				if (response() < 0)
 					exit(1);
 				free(bp);
-				setuid(userid);
+				if (setuid(userid) < 0)
+					errx(1, "setuid failed");
 			}
 			source(1, argv+i);
 		}
@@ -270,7 +273,8 @@ tolocal(int argc, char **argv)
 		}
 		free(bp);
 		sink(1, argv + argc - 1);
-		seteuid(0);
+		if (seteuid(0) < 0)
+			exit(1);
 		close(remin);
 		remin = remout = -1;
 	}
