- deraadt@cvs.openbsd.org 2001/02/04 17:02:32
     [sftp-int.c]
     ? == help
   - deraadt@cvs.openbsd.org 2001/02/04 16:47:46
     [sftp-int.c]
     sort commands, so that abbreviations work as expected
   - stevesk@cvs.openbsd.org 2001/02/04 15:17:52
     [sftp-int.c]
     debugging sftp: precedence and missing break.  chmod, chown, chgrp
     seem to be working now.
   - markus@cvs.openbsd.org 2001/02/04 14:41:21
     [sftp-int.c]
     use base 8 for umask/chmod
   - markus@cvs.openbsd.org 2001/02/04 11:11:54
     [sftp-int.c]
     fix LCD
diff --git a/ChangeLog b/ChangeLog
index adc970d..689c2b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,22 @@
    - stevesk@cvs.openbsd.org 2001/02/04 15:21:19
      [sftp-server.c]
      SSH2_FILEXFER_ATTR_UIDGID support; ok markus@
+   - deraadt@cvs.openbsd.org 2001/02/04 17:02:32
+     [sftp-int.c]
+     ? == help
+   - deraadt@cvs.openbsd.org 2001/02/04 16:47:46
+     [sftp-int.c]
+     sort commands, so that abbreviations work as expected
+   - stevesk@cvs.openbsd.org 2001/02/04 15:17:52
+     [sftp-int.c]
+     debugging sftp: precedence and missing break.  chmod, chown, chgrp
+     seem to be working now.
+   - markus@cvs.openbsd.org 2001/02/04 14:41:21
+     [sftp-int.c]
+     use base 8 for umask/chmod
+   - markus@cvs.openbsd.org 2001/02/04 11:11:54
+     [sftp-int.c]
+     fix LCD
 
 20010104
  - (bal) I think this is the last of the bsd-*.h that don't belong.
diff --git a/sftp-int.c b/sftp-int.c
index 9ec5b97..02e0d38 100644
--- a/sftp-int.c
+++ b/sftp-int.c
@@ -27,7 +27,7 @@
 /* XXX: recursive operations */
 
 #include "includes.h"
-RCSID("$OpenBSD: sftp-int.c,v 1.1 2001/02/04 11:11:54 djm Exp $");
+RCSID("$OpenBSD: sftp-int.c,v 1.7 2001/02/05 00:02:32 deraadt Exp $");
 
 #include "buffer.h"
 #include "xmalloc.h"
@@ -65,35 +65,36 @@
 #define I_SHELL		20
 
 struct CMD {
-	const int n;
 	const char *c;
+	const int n;
 };
 
 const struct CMD cmds[] = {
-	{ I_CHDIR,	"CD" },
-	{ I_CHDIR,	"CHDIR" },
-	{ I_CHDIR,	"LCD" },
-	{ I_CHGRP,	"CHGRP" },
-	{ I_CHMOD,	"CHMOD" },
-	{ I_CHOWN,	"CHOWN" },
-	{ I_HELP,	"HELP" },
-	{ I_GET,	"GET" },
-	{ I_LCHDIR,	"LCHDIR" },
-	{ I_LLS,	"LLS" },
-	{ I_LMKDIR,	"LMKDIR" },
-	{ I_LPWD,	"LPWD" },
-	{ I_LS,		"LS" },
-	{ I_LUMASK,	"LUMASK" },
-	{ I_MKDIR,	"MKDIR" },
-	{ I_PUT,	"PUT" },
-	{ I_PWD,	"PWD" },
-	{ I_QUIT,	"EXIT" },
-	{ I_QUIT,	"QUIT" },
-	{ I_RENAME,	"RENAME" },
-	{ I_RMDIR,	"RMDIR" },
-	{ I_RM,		"RM" },
-	{ I_SHELL,	"!" },
-	{ -1,		NULL}
+	{ "CD",		I_CHDIR },
+	{ "CHDIR",	I_CHDIR },
+	{ "CHGRP",	I_CHGRP },
+	{ "CHMOD",	I_CHMOD },
+	{ "CHOWN",	I_CHOWN },
+	{ "EXIT",	I_QUIT },
+	{ "GET",	I_GET },
+	{ "HELP",	I_HELP },
+	{ "LCD",	I_LCHDIR },
+	{ "LCHDIR",	I_LCHDIR },
+	{ "LLS",	I_LLS },
+	{ "LMKDIR",	I_LMKDIR },
+	{ "LPWD",	I_LPWD },
+	{ "LS",		I_LS },
+	{ "LUMASK",	I_LUMASK },
+	{ "MKDIR",	I_MKDIR },
+	{ "PUT",	I_PUT },
+	{ "PWD",	I_PWD },
+	{ "QUIT",	I_QUIT },
+	{ "RENAME",	I_RENAME },
+	{ "RM",		I_RM },
+	{ "RMDIR",	I_RMDIR },
+	{ "!",		I_SHELL },
+	{ "?",		I_HELP },
+	{ NULL,			-1}
 };
 
 void
@@ -289,6 +290,7 @@
     char **path1, char **path2)
 {
 	const char *cmd, *cp = *cpp;
+	int base = 0;
 	int i, cmdnum;
 
 	/* Skip leading whitespace */
@@ -383,6 +385,7 @@
 		break;
 	case I_LUMASK:
 	case I_CHMOD:
+		base = 8;
 	case I_CHOWN:
 	case I_CHGRP:
 		/* Get numeric arg (mandatory) */
@@ -391,7 +394,7 @@
 			    "to the %s command.", cmd);
 			return(-1);
 		}
-		*n_arg = strtoul(cp, (char**)&cp, 0);
+		*n_arg = strtoul(cp, (char**)&cp, base);
 		if (!*cp || !strchr(WHITESPACE, *cp)) {
 			error("You must supply a numeric argument "
 			    "to the %s command.", cmd);
@@ -500,10 +503,11 @@
 		a.flags |= SSH2_FILEXFER_ATTR_PERMISSIONS;
 		a.perm = n_arg;
 		do_setstat(in, out, path1, &a);
+		break;
 	case I_CHOWN:
 		path1 = make_absolute(path1, *pwd);
 		aa = do_stat(in, out, path1);
-		if (!aa->flags & SSH2_FILEXFER_ATTR_UIDGID) {
+		if (!(aa->flags & SSH2_FILEXFER_ATTR_UIDGID)) {
 			error("Can't get current ownership of "
 			    "remote file \"%s\"", path1);
 			break;
@@ -514,7 +518,7 @@
 	case I_CHGRP:
 		path1 = make_absolute(path1, *pwd);
 		aa = do_stat(in, out, path1);
-		if (!aa->flags & SSH2_FILEXFER_ATTR_UIDGID) {
+		if (!(aa->flags & SSH2_FILEXFER_ATTR_UIDGID)) {
 			error("Can't get current ownership of "
 			    "remote file \"%s\"", path1);
 			break;