mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-21 14:53:44 +03:00
Commited the snprintf patch courtesy of George Katsirelos <gkatsi@cs.toronto.edu>, Daniel.
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
Wed Feb 2 22:51:16 CET 2000 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||||
|
|
||||||
|
* nanoftp.c: snprintf/sprintf patch courtesy George Katsirelos
|
||||||
|
<gkatsi@cs.toronto.edu>
|
||||||
|
|
||||||
Mon Jan 31 18:58:21 CET 2000 Daniel Veillard <Daniel.Veillard@w3.org>
|
Mon Jan 31 18:58:21 CET 2000 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||||
|
|
||||||
* nanoftp.c nanohttp.c: Fixed '#' and '?' stripping when
|
* nanoftp.c nanohttp.c: Fixed '#' and '?' stripping when
|
||||||
|
84
nanoftp.c
84
nanoftp.c
@@ -645,9 +645,17 @@ xmlNanoFTPSendUser(void *ctx) {
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (ctxt->user == NULL)
|
if (ctxt->user == NULL)
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "USER anonymous\r\n");
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "USER anonymous\r\n");
|
len = snprintf(buf, sizeof(buf), "USER anonymous\r\n");
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
else
|
else
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "USER %s\r\n", ctxt->user);
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "USER %s\r\n", ctxt->user);
|
len = snprintf(buf, sizeof(buf), "USER %s\r\n", ctxt->user);
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
printf(buf);
|
||||||
#endif
|
#endif
|
||||||
@@ -668,9 +676,17 @@ xmlNanoFTPSendPasswd(void *ctx) {
|
|||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (ctxt->passwd == NULL)
|
if (ctxt->passwd == NULL)
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "PASS libxml@%s\r\n", hostname);
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "PASS libxml@%s\r\n", hostname);
|
len = snprintf(buf, sizeof(buf), "PASS libxml@%s\r\n", hostname);
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
else
|
else
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "PASS %s\r\n", ctxt->passwd);
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd);
|
len = snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd);
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
printf(buf);
|
||||||
#endif
|
#endif
|
||||||
@@ -696,7 +712,11 @@ xmlNanoFTPQuit(void *ctx) {
|
|||||||
int len;
|
int len;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "QUIT\r\n");
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "QUIT\r\n");
|
len = snprintf(buf, sizeof(buf), "QUIT\r\n");
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
printf(buf);
|
||||||
#endif
|
#endif
|
||||||
@@ -816,7 +836,11 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
/*
|
/*
|
||||||
* We need proxy auth
|
* We need proxy auth
|
||||||
*/
|
*/
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "USER %s\r\n", proxyUser);
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "USER %s\r\n", proxyUser);
|
len = snprintf(buf, sizeof(buf), "USER %s\r\n", proxyUser);
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
printf(buf);
|
||||||
#endif
|
#endif
|
||||||
@@ -833,9 +857,17 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (proxyPasswd != NULL)
|
if (proxyPasswd != NULL)
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "PASS %s\r\n", proxyPasswd);
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "PASS %s\r\n", proxyPasswd);
|
len = snprintf(buf, sizeof(buf), "PASS %s\r\n", proxyPasswd);
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
else
|
else
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "PASS libxml@%s\r\n",
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "PASS libxml@%s\r\n",
|
len = snprintf(buf, sizeof(buf), "PASS libxml@%s\r\n",
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
hostname);
|
hostname);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
printf(buf);
|
||||||
@@ -874,7 +906,11 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
/* we will try in seqence */
|
/* we will try in seqence */
|
||||||
case 1:
|
case 1:
|
||||||
/* Using SITE command */
|
/* Using SITE command */
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "SITE %s\r\n", ctxt->hostname);
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "SITE %s\r\n", ctxt->hostname);
|
len = snprintf(buf, sizeof(buf), "SITE %s\r\n", ctxt->hostname);
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
printf(buf);
|
||||||
#endif
|
#endif
|
||||||
@@ -898,10 +934,18 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
case 2:
|
case 2:
|
||||||
/* USER user@host command */
|
/* USER user@host command */
|
||||||
if (ctxt->user == NULL)
|
if (ctxt->user == NULL)
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "USER anonymous@%s\r\n",
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "USER anonymous@%s\r\n",
|
len = snprintf(buf, sizeof(buf), "USER anonymous@%s\r\n",
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
ctxt->hostname);
|
ctxt->hostname);
|
||||||
else
|
else
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "USER %s@%s\r\n",
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "USER %s@%s\r\n",
|
len = snprintf(buf, sizeof(buf), "USER %s@%s\r\n",
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
ctxt->user, ctxt->hostname);
|
ctxt->user, ctxt->hostname);
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
printf(buf);
|
||||||
@@ -919,9 +963,17 @@ xmlNanoFTPConnect(void *ctx) {
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
if (ctxt->passwd == NULL)
|
if (ctxt->passwd == NULL)
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "PASS libxml@%s\r\n", hostname);
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "PASS libxml@%s\r\n", hostname);
|
len = snprintf(buf, sizeof(buf), "PASS libxml@%s\r\n", hostname);
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
else
|
else
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "PASS %s\r\n", ctxt->passwd);
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd);
|
len = snprintf(buf, sizeof(buf), "PASS %s\r\n", ctxt->passwd);
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
printf(buf);
|
||||||
#endif
|
#endif
|
||||||
@@ -1057,7 +1109,11 @@ xmlNanoFTPCwd(void *ctx, char *directory) {
|
|||||||
* 250
|
* 250
|
||||||
* 500, 501, 502, 421, 530, 550
|
* 500, 501, 502, 421, 530, 550
|
||||||
*/
|
*/
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "CWD %s\r\n", directory);
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "CWD %s\r\n", directory);
|
len = snprintf(buf, sizeof(buf), "CWD %s\r\n", directory);
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
printf(buf);
|
||||||
#endif
|
#endif
|
||||||
@@ -1104,7 +1160,11 @@ xmlNanoFTPGetConnection(void *ctx) {
|
|||||||
dataAddr.sin_family = AF_INET;
|
dataAddr.sin_family = AF_INET;
|
||||||
|
|
||||||
if (ctxt->passive) {
|
if (ctxt->passive) {
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "PASV\r\n");
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "PASV\r\n");
|
len = snprintf(buf, sizeof(buf), "PASV\r\n");
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
printf(buf);
|
||||||
#endif
|
#endif
|
||||||
@@ -1160,7 +1220,11 @@ xmlNanoFTPGetConnection(void *ctx) {
|
|||||||
}
|
}
|
||||||
adp = (unsigned char *) &dataAddr.sin_addr;
|
adp = (unsigned char *) &dataAddr.sin_addr;
|
||||||
portp = (unsigned char *) &dataAddr.sin_port;
|
portp = (unsigned char *) &dataAddr.sin_port;
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "PORT %d,%d,%d,%d,%d,%d\r\n",
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "PORT %d,%d,%d,%d,%d,%d\r\n",
|
len = snprintf(buf, sizeof(buf), "PORT %d,%d,%d,%d,%d,%d\r\n",
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
adp[0] & 0xff, adp[1] & 0xff, adp[2] & 0xff, adp[3] & 0xff,
|
adp[0] & 0xff, adp[1] & 0xff, adp[2] & 0xff, adp[3] & 0xff,
|
||||||
portp[0] & 0xff, portp[1] & 0xff);
|
portp[0] & 0xff, portp[1] & 0xff);
|
||||||
buf[sizeof(buf) - 1] = 0;
|
buf[sizeof(buf) - 1] = 0;
|
||||||
@@ -1359,14 +1423,22 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
|
|||||||
if (xmlNanoFTPCwd(ctxt, ctxt->path) < 1)
|
if (xmlNanoFTPCwd(ctxt, ctxt->path) < 1)
|
||||||
return(-1);
|
return(-1);
|
||||||
ctxt->dataFd = xmlNanoFTPGetConnection(ctxt);
|
ctxt->dataFd = xmlNanoFTPGetConnection(ctxt);
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "LIST -L\r\n");
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "LIST -L\r\n");
|
len = snprintf(buf, sizeof(buf), "LIST -L\r\n");
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
} else {
|
} else {
|
||||||
if (filename[0] != '/') {
|
if (filename[0] != '/') {
|
||||||
if (xmlNanoFTPCwd(ctxt, ctxt->path) < 1)
|
if (xmlNanoFTPCwd(ctxt, ctxt->path) < 1)
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
ctxt->dataFd = xmlNanoFTPGetConnection(ctxt);
|
ctxt->dataFd = xmlNanoFTPGetConnection(ctxt);
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "LIST -L %s\r\n", filename);
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "LIST -L %s\r\n", filename);
|
len = snprintf(buf, sizeof(buf), "LIST -L %s\r\n", filename);
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
printf(buf);
|
||||||
@@ -1458,7 +1530,11 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
|
|||||||
return(-1);
|
return(-1);
|
||||||
ctxt->dataFd = xmlNanoFTPGetConnection(ctxt);
|
ctxt->dataFd = xmlNanoFTPGetConnection(ctxt);
|
||||||
|
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "TYPE I\r\n");
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "TYPE I\r\n");
|
len = snprintf(buf, sizeof(buf), "TYPE I\r\n");
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
printf(buf);
|
||||||
#endif
|
#endif
|
||||||
@@ -1473,9 +1549,17 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
|
|||||||
return(-res);
|
return(-res);
|
||||||
}
|
}
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "RETR %s\r\n", ctxt->path);
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "RETR %s\r\n", ctxt->path);
|
len = snprintf(buf, sizeof(buf), "RETR %s\r\n", ctxt->path);
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
else
|
else
|
||||||
|
#ifndef HAVE_SNPRINTF
|
||||||
|
len = sprintf(buf, "RETR %s\r\n", filename);
|
||||||
|
#else /* HAVE_SNPRINTF */
|
||||||
len = snprintf(buf, sizeof(buf), "RETR %s\r\n", filename);
|
len = snprintf(buf, sizeof(buf), "RETR %s\r\n", filename);
|
||||||
|
#endif /* HAVE_SNPRINTF */
|
||||||
#ifdef DEBUG_FTP
|
#ifdef DEBUG_FTP
|
||||||
printf(buf);
|
printf(buf);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user