PATCH: zftp: fix some mistakes

Mikael Magnusson <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <[email protected]>
The freesession function randomly clearing the current session instead
of the passed section is probably not great.

The h_errno definition is repeated just above identically, which I would
assume is a compile time error for anyone who has USE_LOCAL_H_ERRNO set.
---
 Src/Modules/zftp.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c
index 230ad86f61..ecabf3430b 100644
--- a/Src/Modules/zftp.c
+++ b/Src/Modules/zftp.c
@@ -82,10 +82,6 @@ union zftp_sockaddr {
 #endif
 };
 
-#ifdef USE_LOCAL_H_ERRNO
-int h_errno;
-#endif
-
 /*
  * For FTP block mode
  *
@@ -119,8 +115,8 @@ struct zfheader {
 enum {
     ZFHD_MARK = 16,		/* restart marker */
     ZFHD_ERRS = 32,		/* suspected errors in block */
-    ZFHD_EOFB = 64,		/* block is end of record */
-    ZFHD_EORB = 128		/* block is end of file */
+    ZFHD_EOFB = 64,		/* block is end of file */
+    ZFHD_EORB = 128		/* block is end of record */
 };
 
 typedef int (*readwrite_t)(int, char *, off_t, int);
@@ -2102,7 +2098,7 @@ zftp_params(UNUSED(char *name), char **args, UNUSED(int flags))
 	/* maybe user CTRL-c'd in the middle somewhere */
 	for (aptr = newarr; *aptr; aptr++)
 	    zsfree(*aptr);
-	zfree(newarr, len+1);
+	zfree(newarr, (len+1)*sizeof(char *));
 	return 1;
     }
     if (zfsess->userparams)
@@ -2191,7 +2187,7 @@ zftp_login(char *name, char **args, UNUSED(int flags))
 	int cnt;
 	for (cnt = 0; *args; args++)
 	    cnt++;
-	zwarnnam(name, "warning: %d command arguments not used\n", cnt);
+	zwarnnam(name, "warning: %d command arguments not used", cnt);
     }
     zfstatusp[zfsessno] |= ZFST_LOGI;
     zfsetparam("ZFTP_USER", ztrdup(user), ZFPM_READONLY);
@@ -2480,7 +2476,7 @@ zftp_mode(char *name, char **args, UNUSED(int flags))
     cmd[5] = (char) nt;
     if (zfsendcmd(cmd) > 2)
 	return 1;
-    zfstatusp[zfsessno] &= ZFST_MMSK;
+    zfstatusp[zfsessno] &= ~ZFST_MMSK;
     zfstatusp[zfsessno] |= (nt == 'S') ? ZFST_STRE : ZFST_BLOC;
     zfsetparam("ZFTP_MODE", ztrdup(str), ZFPM_READONLY);
     return 0;
@@ -2875,10 +2871,10 @@ freesession(Zftp_session sptr)
 {
     char **ps, **pd;
     zsfree(sptr->name);
-    for (ps = zfparams, pd = zfsess->params; *ps; ps++, pd++)
+    for (ps = zfparams, pd = sptr->params; *ps; ps++, pd++)
 	if (*pd)
 	    zsfree(*pd);
-    zfree(zfsess->params, sizeof(zfparams));
+    zfree(sptr->params, sizeof(zfparams));
     if (sptr->userparams)
 	freearray(sptr->userparams);
     zfree(sptr, sizeof(struct zftp_session));
-- 
2.38.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.