1 --- libxml-1.8.17.orig/nanoftp.c
2 +++ libxml-1.8.17/nanoftp.c
4 #define FTP_GET_PASSWD 331
5 #define FTP_BUF_SIZE 512
7 +#define XML_NANO_MAX_URLBUF 4096
9 typedef struct xmlNanoFTPCtxt {
10 char *protocol; /* the protocol name */
11 char *hostname; /* the host name */
13 xmlNanoFTPScanURL(void *ctx, const char *URL) {
14 xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx;
15 const char *cur = URL;
17 + char buf[XML_NANO_MAX_URLBUF];
23 if (URL == NULL) return;
26 + while ((*cur != 0) && (index < XML_NANO_MAX_URLBUF - 1)) {
27 if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) {
29 ctxt->protocol = xmlMemStrdup(buf);
31 if (*cur == 0) return;
35 + while (index < (XML_NANO_MAX_URLBUF - 1)) {
38 ctxt->hostname = xmlMemStrdup(buf);
44 + while ((*cur != 0) && (index < XML_NANO_MAX_URLBUF-1))
45 buf[index++] = *cur++;
47 ctxt->path = xmlMemStrdup(buf);
49 xmlNanoFTPUpdateURL(void *ctx, const char *URL) {
50 xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx;
51 const char *cur = URL;
53 + char buf[XML_NANO_MAX_URLBUF];
58 if (ctxt->hostname == NULL)
62 + while ((*cur != 0) && (index < XML_NANO_MAX_URLBUF-1)) {
63 if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) {
65 if (strcmp(ctxt->protocol, buf))
71 + while (index < (XML_NANO_MAX_URLBUF - 1)) {
74 if (strcmp(ctxt->hostname, buf))
80 + while ((*cur != 0) && (index < XML_NANO_MAX_URLBUF-1))
81 buf[index++] = *cur++;
83 ctxt->path = xmlMemStrdup(buf);
86 xmlNanoFTPScanProxy(const char *URL) {
87 const char *cur = URL;
89 + char buf[XML_NANO_MAX_URLBUF];
95 if (URL == NULL) return;
98 + while ((*cur != 0) && (index < XML_NANO_MAX_URLBUF-1)) {
99 if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) {
103 if (*cur == 0) return;
107 + while (index < (XML_NANO_MAX_URLBUF - 1)) {
110 proxy = xmlMemStrdup(buf);
111 --- libxml-1.8.17.orig/nanohttp.c
112 +++ libxml-1.8.17/nanohttp.c
114 const char *cur = URL;
117 + const int indexMax = 4096 - 1;
120 if (ctxt->protocol != NULL) {
123 if (URL == NULL) return;
125 - while (*cur != 0) {
126 + while ((*cur != 0) && (index < indexMax)) {
127 if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) {
129 ctxt->protocol = xmlMemStrdup(buf);
131 if (*cur == 0) return;
135 + while (index < indexMax) {
138 ctxt->hostname = xmlMemStrdup(buf);
144 + while ((*cur != 0) && (index < indexMax))
145 buf[index++] = *cur++;
147 ctxt->path = xmlMemStrdup(buf);
149 const char *cur = URL;
152 + const int indexMax = 4096 - 1;
158 if (URL == NULL) return;
160 - while (*cur != 0) {
161 + while ((*cur != 0) && (index < indexMax)) {
162 if ((cur[0] == ':') && (cur[1] == '/') && (cur[2] == '/')) {
166 if (*cur == 0) return;
170 + while (index < indexMax) {
173 proxy = xmlMemStrdup(buf);