head 1.2; access; symbols OPENPKG_E1_MP_HEAD:1.2 OPENPKG_E1_MP:1.2 OPENPKG_E1_MP_2_STABLE:1.2.2.2 OPENPKG_E1_FP:1.2.2.2 OPENPKG_2_STABLE_MP:1.2 OPENPKG_2_STABLE_20061018:1.2.2.2 OPENPKG_2_STABLE:1.2.0.2 OPENPKG_CW_FP:1.1 OPENPKG_1_STABLE_MP:1.1; locks; strict; comment @# @; 1.2 date 2006.03.23.21.27.03; author rse; state Exp; branches 1.2.2.1; next 1.1; commitid xNvdJEMMMdatRlqr; 1.1 date 2002.06.14.12.48.53; author rse; state Exp; branches; next ; 1.2.2.1 date 2006.03.23.21.27.03; author rse; state dead; branches; next 1.2.2.2; commitid iZxwRSmmWscPXUQr; 1.2.2.2 date 2006.10.16.14.56.42; author rse; state Exp; branches; next ; commitid iZxwRSmmWscPXUQr; desc @@ 1.2 log @apply a patch from the FreeBSD ports tree which fixes reply code handling for USER command @ text @Index: e_err.c --- e_err.c.orig 2000-05-14 16:39:39 +0200 +++ e_err.c 2006-03-23 22:22:39 +0100 @@@@ -115,6 +115,7 @@@@ } res = vsnprintf(p, len, fmt, args); + if (res >= len) res = len - 1; len -= res; p += res; Index: jftp.c --- jftp.c.orig 2000-05-27 15:47:43 +0200 +++ jftp.c 2006-03-23 22:22:39 +0100 @@@@ -40,6 +40,7 @@@@ #include #include +#include #include #include #include @@@@ -220,6 +221,7 @@@@ int ftp_status, eol, i, islongtext; ssize_t done, res, size, pos; char *nfmt; + char rescode[5]; if (*fmt != ' ') { if ((nfmt = alloca(strlen(fmt) + 3)) == NULL) { @@@@ -267,12 +269,28 @@@@ pos += done; if(eol) { ftp_status=0; - res = sscanf(c->ftp_buf, "%3d", &ftp_status); - if ((res == 1) && (ftp_status >= 100) && (ftp_status <= 999)) { - /* We have a line that contains a valid reply code */ - /* This may be the start of a multi line reply */ - islongtext = (c->ftp_buf[3] == '-'); + /* We are interested in the first 4 bytes */ + (void)memset(rescode, '\0', sizeof(rescode)); + (void)memcpy(rescode, c->ftp_buf, sizeof(rescode) - 1); + + if (isdigit(rescode[0]) + && isdigit(rescode[1]) + && isdigit(rescode[2])) { + res = sscanf(rescode, "%3d", &ftp_status); + + E_LOGX_1(3, "ftp_status: %d", ftp_status); + E_LOGX_1(3, "c->ftp_buf: %s", c->ftp_buf); + + if ((rescode[3] == '-' || rescode[3] == ' ') + && (res == 1)) { + islongtext = (rescode[3] == '-'); + if (ftp_status < 100) { + E_LOGX_1(1, "%s", c->ftp_buf); + c->ftp_resp = JFTP_ERR; + return -1; + } + } } if(islongtext) { size = sizeof(c->ftp_buf); @@@@ -423,17 +441,22 @@@@ c->ftp_resp = JFTP_ERR; return -1; } - if (ftp_req(c, "user %s", c->ftp_user_name) < 0 || c->ftp_resp != 331) { + if (ftp_req(c, "user %s", c->ftp_user_name) < 0 + || (c->ftp_resp != 331 && c->ftp_resp != 230)) { E_LOGX_1(0, "Username %s: failed", c->ftp_user_name); FD_CLOSE(c->ftp_com); c->ftp_resp = JFTP_ERR; return -1; } - if (ftp_req(c, "pass %s", c->ftp_password) < 0 || c->ftp_resp != 230) { - E_LOGX(0, "Password xxxxx: failed"); - FD_CLOSE(c->ftp_com); - c->ftp_resp = JFTP_ERR; - return -1; + /* USER command can respond 230 immediately in some cases */ + if (c->ftp_resp != 230) { + if (ftp_req(c, "pass %s", c->ftp_password) < 0 + || c->ftp_resp != 230) { + E_LOGX(0, "Password xxxxx: failed"); + FD_CLOSE(c->ftp_com); + c->ftp_resp = JFTP_ERR; + return -1; + } } c->ftp_resp = 0; if (ftp_req(c, "TYPE I") < 0 || c->ftp_resp != 200) { @@@@ -836,7 +859,7 @@@@ /* Late versions of wu-ftpd does some kind of recursive * listing if only a '.' is given as directory. */ - if (strcmp(dir, ".") == 0) + if ((strcmp(dir, ".") == 0) || !*dir) res = ftp_req(c, "list %s", flags); else res = ftp_req(c, "list %s %s", flags, dir); Index: spegla.c --- spegla.c.orig 2000-05-27 15:38:14 +0200 +++ spegla.c 2006-03-23 22:22:39 +0100 @@@@ -728,7 +728,7 @@@@ #ifdef ULTRIX if ((f.fd_req.bfreen * 1024) < minfree) #else - if ((f.f_bsize * f.f_bavail) < minfree) + if (((long long)f.f_bsize * f.f_bavail) < minfree) #endif e_errx(1, "%s: Not enough space left", path); @@@@ -953,6 +953,7 @@@@ } buf[i] = p[j]; } + buf[i] = '\0'; *val = buf; ret: if (show) @ 1.2.2.1 log @file spegla.patch was added on branch OPENPKG_2_STABLE on 2006-10-16 14:56:42 +0000 @ text @d1 122 @ 1.2.2.2 log @Mass merge from CURRENT to 2-STABLE (all packages except those of JUNK class) @ text @a0 122 Index: e_err.c --- e_err.c.orig 2000-05-14 16:39:39 +0200 +++ e_err.c 2006-03-23 22:22:39 +0100 @@@@ -115,6 +115,7 @@@@ } res = vsnprintf(p, len, fmt, args); + if (res >= len) res = len - 1; len -= res; p += res; Index: jftp.c --- jftp.c.orig 2000-05-27 15:47:43 +0200 +++ jftp.c 2006-03-23 22:22:39 +0100 @@@@ -40,6 +40,7 @@@@ #include #include +#include #include #include #include @@@@ -220,6 +221,7 @@@@ int ftp_status, eol, i, islongtext; ssize_t done, res, size, pos; char *nfmt; + char rescode[5]; if (*fmt != ' ') { if ((nfmt = alloca(strlen(fmt) + 3)) == NULL) { @@@@ -267,12 +269,28 @@@@ pos += done; if(eol) { ftp_status=0; - res = sscanf(c->ftp_buf, "%3d", &ftp_status); - if ((res == 1) && (ftp_status >= 100) && (ftp_status <= 999)) { - /* We have a line that contains a valid reply code */ - /* This may be the start of a multi line reply */ - islongtext = (c->ftp_buf[3] == '-'); + /* We are interested in the first 4 bytes */ + (void)memset(rescode, '\0', sizeof(rescode)); + (void)memcpy(rescode, c->ftp_buf, sizeof(rescode) - 1); + + if (isdigit(rescode[0]) + && isdigit(rescode[1]) + && isdigit(rescode[2])) { + res = sscanf(rescode, "%3d", &ftp_status); + + E_LOGX_1(3, "ftp_status: %d", ftp_status); + E_LOGX_1(3, "c->ftp_buf: %s", c->ftp_buf); + + if ((rescode[3] == '-' || rescode[3] == ' ') + && (res == 1)) { + islongtext = (rescode[3] == '-'); + if (ftp_status < 100) { + E_LOGX_1(1, "%s", c->ftp_buf); + c->ftp_resp = JFTP_ERR; + return -1; + } + } } if(islongtext) { size = sizeof(c->ftp_buf); @@@@ -423,17 +441,22 @@@@ c->ftp_resp = JFTP_ERR; return -1; } - if (ftp_req(c, "user %s", c->ftp_user_name) < 0 || c->ftp_resp != 331) { + if (ftp_req(c, "user %s", c->ftp_user_name) < 0 + || (c->ftp_resp != 331 && c->ftp_resp != 230)) { E_LOGX_1(0, "Username %s: failed", c->ftp_user_name); FD_CLOSE(c->ftp_com); c->ftp_resp = JFTP_ERR; return -1; } - if (ftp_req(c, "pass %s", c->ftp_password) < 0 || c->ftp_resp != 230) { - E_LOGX(0, "Password xxxxx: failed"); - FD_CLOSE(c->ftp_com); - c->ftp_resp = JFTP_ERR; - return -1; + /* USER command can respond 230 immediately in some cases */ + if (c->ftp_resp != 230) { + if (ftp_req(c, "pass %s", c->ftp_password) < 0 + || c->ftp_resp != 230) { + E_LOGX(0, "Password xxxxx: failed"); + FD_CLOSE(c->ftp_com); + c->ftp_resp = JFTP_ERR; + return -1; + } } c->ftp_resp = 0; if (ftp_req(c, "TYPE I") < 0 || c->ftp_resp != 200) { @@@@ -836,7 +859,7 @@@@ /* Late versions of wu-ftpd does some kind of recursive * listing if only a '.' is given as directory. */ - if (strcmp(dir, ".") == 0) + if ((strcmp(dir, ".") == 0) || !*dir) res = ftp_req(c, "list %s", flags); else res = ftp_req(c, "list %s %s", flags, dir); Index: spegla.c --- spegla.c.orig 2000-05-27 15:38:14 +0200 +++ spegla.c 2006-03-23 22:22:39 +0100 @@@@ -728,7 +728,7 @@@@ #ifdef ULTRIX if ((f.fd_req.bfreen * 1024) < minfree) #else - if ((f.f_bsize * f.f_bavail) < minfree) + if (((long long)f.f_bsize * f.f_bavail) < minfree) #endif e_errx(1, "%s: Not enough space left", path); @@@@ -953,6 +953,7 @@@@ } buf[i] = p[j]; } + buf[i] = '\0'; *val = buf; ret: if (show) @ 1.1 log @new package: spegla 1.1p4 (FTP Mirroring Tool) @ text @d1 3 a3 2 --- e_err.c.orig Sun May 14 23:39:39 2000 +++ e_err.c Thu Feb 1 15:38:37 2001 d12 94 a105 2 --- spegla.c.orig Sat May 27 22:38:14 2000 +++ spegla.c Thu Feb 1 15:39:24 2001 @