* don't use strlen and strcpy over here too in a wrong way.
authorWilfried Göesgens <willi@citadel.org>
Wed, 4 Jul 2007 21:58:19 +0000 (21:58 +0000)
committerWilfried Göesgens <willi@citadel.org>
Wed, 4 Jul 2007 21:58:19 +0000 (21:58 +0000)
webcit/webcit.c

index aef8b0a24c19bf307fc2fcafa5eb4b5dcc01eec7..36c4fe8f7c19027c2c7a8d418c694ef629c6801e 100644 (file)
@@ -28,11 +28,16 @@ void unescape_input(char *buf)
 {
        int a, b;
        char hex[3];
+       long buflen;
 
-       while ((isspace(buf[strlen(buf) - 1])) && (strlen(buf) > 0))
-               buf[strlen(buf) - 1] = 0;
+       buflen = strlen(buf);
 
-       for (a = 0; a < strlen(buf); ++a) {
+       while ((isspace(buf[buflen - 1])) && (buflen > 0)){
+               buf[buflen - 1] = 0;
+               buflen --;
+       }
+
+       for (a = 0; a < buflen; ++a) {
                if (buf[a] == '+')
                        buf[a] = ' ';
                if (buf[a] == '%') {
@@ -42,7 +47,9 @@ void unescape_input(char *buf)
                        b = 0;
                        sscanf(hex, "%02x", &b);
                        buf[a] = (char) b;
-                       strcpy(&buf[a + 1], &buf[a + 3]);
+                       memmove(&buf[a + 1], &buf[a + 3], buflen - a - 2);
+                       
+                       buflen -=2;
                }
        }