www-apache-bugdb mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Life is hard, and then you die." <ron...@innovation.ch>
Subject Re: other/3411: [PATCH] ap_uuencode() has number of bugs
Date Fri, 20 Nov 1998 09:21:58 GMT

Oops, just realized a bug in the EBCDIC part of the patch - os_toebcdic[]
isn't necessary because basis_64[] is already appropriate. So here is
the patch again:

--- main/util.c.orig    Fri Nov  6 18:12:27 1998
+++ main/util.c Wed Nov 18 20:03:40 1998
@@ -1749,18 +1749,44 @@
 { 
     int i, len = strlen(string); 
     char *p; 
-    char *encoded = (char *) ap_pcalloc(a, (len+2) / 3 * 4); 
+    char *encoded = (char *) ap_palloc(a, (len+2) / 3 * 4); 
  
     p = encoded; 
-    for (i = 0; i < len; i += 3) { 
-        *p++ = basis_64[string[i] >> 2]; 
+#ifndef CHARSET_EBCDIC
+    for (i = 0; i < len-2; i += 3) { 
+        *p++ = basis_64[(string[i] >> 2) & 0x3F]; 
         *p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] &
0xF0) >> 4)]; 
         *p++ = basis_64[((string[i + 1] & 0xF) << 2) | ((int) (string[i + 2] &
0xC0) >> 6)]; 
         *p++ = basis_64[string[i + 2] & 0x3F]; 
     } 
-    *p-- = '\0'; 
-    *p-- = '='; 
-    *p-- = '='; 
+    if (i < len) {
+        *p++ = basis_64[(string[i] >> 2) & 0x3F]; 
+       *p++ = basis_64[((string[i] & 0x3) << 4) | ((int) (string[i + 1] & 0xF0)
>> 4)]; 
+       if (i == (len-2))
+           *p++ = basis_64[((string[i + 1] & 0xF) << 2)]; 
+       else
+           *p++ = '='; 
+       *p++ = '='; 
+    }
+#else /*CHARSET_EBCDIC*/
+    for (i = 0; i < len-2; i += 3) { 
+        *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F]; 
+        *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) | ((int) (os_toascii[string[i
+ 1]] & 0xF0) >> 4)]; 
+        *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2) | ((int) (os_toascii[string[i
+ 2]] & 0xC0) >> 6)]; 
+        *p++ = basis_64[os_toascii[string[i + 2]] & 0x3F]; 
+    } 
+    if (i < len) {
+        *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F]; 
+       *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) | ((int) (os_toascii[string[i
+ 1]] & 0xF0) >> 4)]; 
+       if (i == (len-2))
+           *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2)]; 
+       else
+           *p++ = '='; 
+       *p++ = '='; 
+    }
+#endif /*CHARSET_EBCDIC*/
+
+    *p = '\0'; 
     return encoded; 
 } 
 

Mime
View raw message