1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-19 14:50:07 +03:00

Commited the snprintf patch courtesy of George Katsirelos <gkatsi@cs.toronto.edu>, Daniel.

This commit is contained in:
Daniel Veillard 2000-02-01 23:59:15 +00:00
parent 726e879614
commit 13c757ef89
2 changed files with 89 additions and 0 deletions

View File

@ -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>
* nanoftp.c nanohttp.c: Fixed '#' and '?' stripping when

View File

@ -645,9 +645,17 @@ xmlNanoFTPSendUser(void *ctx) {
int res;
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");
#endif /* HAVE_SNPRINTF */
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);
#endif /* HAVE_SNPRINTF */
#ifdef DEBUG_FTP
printf(buf);
#endif
@ -668,9 +676,17 @@ xmlNanoFTPSendPasswd(void *ctx) {
int res;
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);
#endif /* HAVE_SNPRINTF */
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);
#endif /* HAVE_SNPRINTF */
#ifdef DEBUG_FTP
printf(buf);
#endif
@ -696,7 +712,11 @@ xmlNanoFTPQuit(void *ctx) {
int len;
int res;
#ifndef HAVE_SNPRINTF
len = sprintf(buf, "QUIT\r\n");
#else /* HAVE_SNPRINTF */
len = snprintf(buf, sizeof(buf), "QUIT\r\n");
#endif /* HAVE_SNPRINTF */
#ifdef DEBUG_FTP
printf(buf);
#endif
@ -816,7 +836,11 @@ xmlNanoFTPConnect(void *ctx) {
/*
* 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);
#endif /* HAVE_SNPRINTF */
#ifdef DEBUG_FTP
printf(buf);
#endif
@ -833,9 +857,17 @@ xmlNanoFTPConnect(void *ctx) {
break;
case 3:
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);
#endif /* HAVE_SNPRINTF */
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",
#endif /* HAVE_SNPRINTF */
hostname);
#ifdef DEBUG_FTP
printf(buf);
@ -874,7 +906,11 @@ xmlNanoFTPConnect(void *ctx) {
/* we will try in seqence */
case 1:
/* 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);
#endif /* HAVE_SNPRINTF */
#ifdef DEBUG_FTP
printf(buf);
#endif
@ -898,10 +934,18 @@ xmlNanoFTPConnect(void *ctx) {
case 2:
/* USER user@host command */
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",
#endif /* HAVE_SNPRINTF */
ctxt->hostname);
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",
#endif /* HAVE_SNPRINTF */
ctxt->user, ctxt->hostname);
#ifdef DEBUG_FTP
printf(buf);
@ -919,9 +963,17 @@ xmlNanoFTPConnect(void *ctx) {
return(0);
}
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);
#endif /* HAVE_SNPRINTF */
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);
#endif /* HAVE_SNPRINTF */
#ifdef DEBUG_FTP
printf(buf);
#endif
@ -1057,7 +1109,11 @@ xmlNanoFTPCwd(void *ctx, char *directory) {
* 250
* 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);
#endif /* HAVE_SNPRINTF */
#ifdef DEBUG_FTP
printf(buf);
#endif
@ -1104,7 +1160,11 @@ xmlNanoFTPGetConnection(void *ctx) {
dataAddr.sin_family = AF_INET;
if (ctxt->passive) {
#ifndef HAVE_SNPRINTF
len = sprintf(buf, "PASV\r\n");
#else /* HAVE_SNPRINTF */
len = snprintf(buf, sizeof(buf), "PASV\r\n");
#endif /* HAVE_SNPRINTF */
#ifdef DEBUG_FTP
printf(buf);
#endif
@ -1160,7 +1220,11 @@ xmlNanoFTPGetConnection(void *ctx) {
}
adp = (unsigned char *) &dataAddr.sin_addr;
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",
#endif /* HAVE_SNPRINTF */
adp[0] & 0xff, adp[1] & 0xff, adp[2] & 0xff, adp[3] & 0xff,
portp[0] & 0xff, portp[1] & 0xff);
buf[sizeof(buf) - 1] = 0;
@ -1359,14 +1423,22 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
if (xmlNanoFTPCwd(ctxt, ctxt->path) < 1)
return(-1);
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");
#endif /* HAVE_SNPRINTF */
} else {
if (filename[0] != '/') {
if (xmlNanoFTPCwd(ctxt, ctxt->path) < 1)
return(-1);
}
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);
#endif /* HAVE_SNPRINTF */
}
#ifdef DEBUG_FTP
printf(buf);
@ -1458,7 +1530,11 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
return(-1);
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");
#endif /* HAVE_SNPRINTF */
#ifdef DEBUG_FTP
printf(buf);
#endif
@ -1473,9 +1549,17 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
return(-res);
}
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);
#endif /* HAVE_SNPRINTF */
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);
#endif /* HAVE_SNPRINTF */
#ifdef DEBUG_FTP
printf(buf);
#endif