Package: webfs / 1.21+ds1-12

50_quote_call.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Description: Resolve inconsistent signedness use by quote( , ).
 The source code is written with indiscriminate use of string types
 'char *' and 'unsigned char *' when it comes to translate back and
 forth between url-encoded and unix-path encoded strings.
 .
 In 'quote( , )' the string 'buf[2048]' is indeed only used to store
 true ASCII-characters, it is thus now declared using 'char *'.
 In this function the first argument can contain extended ASCII
 characters, so strlen() for the same argument can use a cast,
 since it only searches for the terminating null character.
 .
 Three calls to 'quote( , )' are legitimate, but need to use a cast
 to unsigned character strings in order to fit the prototype.
Author: Mats Erik Andersson <mats.andersson@gisladisker.se>
Forwarded: no
Last-Update: 2010-01-27
--- webfs-1.21.orig/ls.c	2004-06-10 11:45:50.000000000 +0200
+++ webfs-1.21/ls.c	2010-01-27 00:37:37.000000000 +0100
@@ -142,8 +142,8 @@
 char*
 quote(unsigned char *path, int maxlength)
 {
-    static unsigned char buf[2048]; /* FIXME: threads break this... */
-    int i,j,n=strlen(path);
+    static char buf[2048]; /* FIXME: threads break this... */
+    int i,j,n=strlen((char *)path);
 
     if (n > maxlength)
 	n = maxlength;
@@ -282,7 +282,7 @@
 	    buf = re2;
 	}
 	len += sprintf(buf+len,"<a href=\"%s\">%*.*s</a>",
-		       quote(path,h2-path),
+		       quote((unsigned char *) path,h2-path),
 		       (int)(h2-h1),
 		       (int)(h2-h1),
 		       h1);
@@ -362,7 +362,7 @@
 	/* filename */
 	if (files[i]->r) {
 	    len += sprintf(buf+len,"<a href=\"%s%s\">%s</a>\n",
-			   quote(files[i]->n,9999),
+			   quote((unsigned char *) files[i]->n,9999),
 			   S_ISDIR(files[i]->s.st_mode) ? "/" : "",
 			   files[i]->n);
 	} else {
--- webfs-1.21.orig/response.c	2004-06-10 11:45:50.000000000 +0200
+++ webfs-1.21/response.c	2010-01-27 00:55:37.000000000 +0100
@@ -219,7 +219,8 @@
 			"Content-Length: %" PRId64 "\r\n",
 			"302 Redirect",server_name,
 			req->keep_alive ? "Keep-Alive" : "Close",
-			req->hostname,tcp_port,quote(req->path,9999),
+			req->hostname,tcp_port,
+			quote((unsigned char *) req->path,9999),
 			(int64_t)req->lbody);
     req->lres += strftime(req->hres+req->lres,80,
 			  "Date: " RFC1123 "\r\n\r\n",