SNAP 20010213 Bug: ssh-agent environment

mouring at etoh.eviladmin.org mouring at etoh.eviladmin.org
Tue Feb 20 06:56:18 EST 2001


On Mon, 19 Feb 2001, Volker Paulsen wrote:

> On Mon, Feb 19, 2001 at 09:27:54PM +1100, Damien Miller wrote:
> > > It does not inherit its environment if it is invoked as
> > > 
> > >     ssh-agent command
> > >     > ssh-agent /bin/sh
> > >     $ env
> > >     SSH_AGENT_PID=19437
> > 
> > Can't replicate this - I get a full env.
> 
> Finally, I tracked the problem down to openbsd-compat/setenv.c in SNAP
> 20010213: memmove() parameters were swapped. Probably this was already
> fixed in some newer SNAP?
> 
> paulsen at tarifa 20:24 [openssh] diff -u openbsd-compat/setenv.c.orig openbsd-compat/setenv.c

<massinve swearing>

Shoot me.. Shoot me now.  <sigh>

The patch that did that occured Jan 5.  It was when I moved from
bcopy() to memmove().  And I forgot to swap the arguments.  This patch
includes your and a fix to getcwd.c  which was the other place I fubared
it.  

Wonder why I never ran into this under NeXT?!  

- Ben

Index: openbsd-compat/getcwd.c
===================================================================
RCS file: /var/cvs/openssh/openbsd-compat/getcwd.c,v
retrieving revision 1.1
diff -u -r1.1 getcwd.c
--- openbsd-compat/getcwd.c	2001/01/31 21:52:03	1.1
+++ openbsd-compat/getcwd.c	2001/02/19 19:48:19
@@ -119,7 +119,7 @@
 			 * path to the beginning of the buffer, but it's always
 			 * been that way and stuff would probably break.
 			 */
-			memmove(bpt, pt, ept - bpt);
+			memmove(pt, bpt, ept - bpt);
 			free(up);
 			return (pt);
 		}
@@ -170,7 +170,7 @@
 					goto notfound;
 				if (ISDOT(dp))
 					continue;
-				memmove(dp->d_name, bup, dp->d_namlen + 1);
+				memmove(bup, dp->d_name, dp->d_namlen + 1);
 
 				/* Save the first error for later. */
 				if (lstat(up, &s)) {
@@ -202,13 +202,13 @@
 			pt = npt;
 			bpt = pt + off;
 			ept = pt + ptsize;
-			memmove(bpt, ept - len, len);
+			memmove(ept - len, bpt, len);
 			bpt = ept - len;
 		}
 		if (!first)
 			*--bpt = '/';
 		bpt -= dp->d_namlen;
-		memmove(dp->d_name, bpt, dp->d_namlen);
+		memmove(bpt, dp->d_name, dp->d_namlen);
 		(void)closedir(dir);
 
 		/* Truncate any file name. */
Index: openbsd-compat/setenv.c
===================================================================
RCS file: /var/cvs/openssh/openbsd-compat/setenv.c,v
retrieving revision 1.1
diff -u -r1.1 setenv.c
--- openbsd-compat/setenv.c	2001/01/31 21:52:04	1.1
+++ openbsd-compat/setenv.c	2001/02/19 19:48:20
@@ -122,7 +122,7 @@
 			    (cnt + 2)));
 			if (!P)
 				return (-1);
-			memmove(environ, P, cnt * sizeof(char *));
+			memmove(P, environ, cnt * sizeof(char *));
 			environ = P;
 		}
 		environ[cnt + 1] = NULL;






More information about the openssh-unix-dev mailing list