- correct some dubious use of strlen() in the ftp client

This commit is contained in:
Nalin Dahyabhai 2009-06-26 21:35:25 +00:00
parent 525e89b7fd
commit d7d96cfa8f

33
krb5-1.7-sizeof.patch Normal file
View File

@ -0,0 +1,33 @@
Surely "buf[strlen(buf)] = '\0'" doesn't do what we intend. RT#TBD
diff -up krb5-1.7/src/appl/gssftp/ftp/ftp.c krb5-1.7/src/appl/gssftp/ftp/ftp.c
--- krb5-1.7/src/appl/gssftp/ftp/ftp.c 2009-06-22 16:03:48.000000000 -0400
+++ krb5-1.7/src/appl/gssftp/ftp/ftp.c 2009-06-22 16:06:28.000000000 -0400
@@ -1663,21 +1663,21 @@ void pswitch(int flag)
ip->ntflg = ntflag;
ntflag = op->ntflg;
(void) strncpy(ip->nti, ntin, sizeof(ip->nti) - 1);
- (ip->nti)[strlen(ip->nti)] = '\0';
+ (ip->nti)[sizeof(ip->nti) - 1] = '\0';
(void) strncpy(ntin, op->nti, sizeof(ntin) - 1);
ntin[sizeof(ntin) - 1] = '\0';
(void) strncpy(ip->nto, ntout, sizeof(ip->nto) - 1);
- (ip->nto)[strlen(ip->nto)] = '\0';
+ (ip->nto)[sizeof(ip->nto) - 1] = '\0';
(void) strncpy(ntout, op->nto, sizeof(ntout) - 1);
ntout[sizeof(ntout) - 1] = '\0';
ip->mapflg = mapflag;
mapflag = op->mapflg;
- (void) strncpy(ip->mi, mapin, MAXPATHLEN - 1);
- (ip->mi)[strlen(ip->mi)] = '\0';
+ (void) strncpy(ip->mi, mapin, sizeof(ip->mi) - 1);
+ (ip->mi)[sizeof(ip->mi) - 1] = '\0';
(void) strncpy(mapin, op->mi, sizeof(mapin) - 1);
mapin[sizeof(mapin) - 1] = '\0';
- (void) strncpy(ip->mo, mapout, MAXPATHLEN - 1);
- (ip->mo)[strlen(ip->mo)] = '\0';
+ (void) strncpy(ip->mo, mapout, sizeof(ip->mo) - 1);
+ (ip->mo)[sizeof(ip->mo) - 1] = '\0';
(void) strncpy(mapout, op->mo, sizeof(mapout) - 1);
mapout[sizeof(mapout) - 1] = '\0';
ip->authtype = auth_type;