]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Yannick Bergeron <yaberger@ca.ibm.com>
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 29 Mar 2010 22:47:44 +0000 (10:47 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 29 Mar 2010 22:47:44 +0000 (10:47 +1200)
Author: Amos Jeffries <squid3@treenet.co.nz>
AIX build fixes

Yannick:
 C code in strict compilers

Amos:
 rfc1738 buffer overflow prevention

include/rfc2181.h
lib/getfullhostname.c
lib/rfc1738.c

index d5c7e1b6a2cb8476f207cdd4c2f71e2f787729e5..197998b874b82a477c5ffc46b2b08b258450e921 100644 (file)
@@ -21,7 +21,7 @@
  */
 #define RFC2181_MAXHOSTNAMELEN 256
 
-/// Back-port macro for old squid code still using SQUIDHOSTNAMELEN without RFC reference.
+/** Back-port macro for old squid code still using SQUIDHOSTNAMELEN without RFC reference. */
 #define SQUIDHOSTNAMELEN       RFC2181_MAXHOSTNAMELEN
 
 #endif /* _SQUID_INCLUDE_RFC1123_H */
index 7b1caa6aa28986ce1b337202b44291e8d1489e34..b7480b2673c2b118756b7c923e975253324754dd 100644 (file)
@@ -62,7 +62,7 @@
 #include <arpa/inet.h>
 #endif
 
-#endif // 0
+#endif /* 0 */
 
 
 #if HAVE_UNISTD_H
index a0edaf75761553e0287f17e60577d87bb9ee0038..6158375686ce9807af87b5cbda44be247258e26a 100644 (file)
@@ -133,7 +133,7 @@ rfc1738_do_escape(const char *url, int flags)
          * allocated - KA */
 
         if (do_escape == 1) {
-            (void) sprintf(q, "%%%02X", (unsigned char) *p);
+            (void) snprintf(q, (bufsize-(p-buf)), "%%%02X", (unsigned char) *p);
             q += sizeof(char) * 2;
         } else {
             *q = *p;
@@ -143,43 +143,10 @@ rfc1738_do_escape(const char *url, int flags)
     return (buf);
 }
 
-#if 0 /* legacy API */
 /*
- * rfc1738_escape - Returns a static buffer that contains the RFC
- * 1738 compliant, escaped version of the given url.
+ * Converts a ascii hex code into a binary character.
  */
-char *
-rfc1738_escape(const char *url)
-{
-    return rfc1738_do_escape(url, 0);
-}
-
-/*
- * rfc1738_escape_unescaped - Returns a static buffer that contains
- * the RFC 1738 compliant, escaped version of the given url.
- */
-char *
-rfc1738_escape_unescaped(const char *url)
-{
-    return rfc1738_do_escape(url, -1);
-}
-
-/*
- * rfc1738_escape_part - Returns a static buffer that contains the
- * RFC 1738 compliant, escaped version of the given url segment.
- */
-char *
-rfc1738_escape_part(const char *url)
-{
-    return rfc1738_do_escape(url, 1);
-}
-#endif /* 0 */
-
-/*
- *  rfc1738_unescape() - Converts escaped characters (%xy numbers) in
- *  given the string.  %% is a %. %ab is the 8-bit hexadecimal number "ab"
- */
-static inline int
+static int
 fromhex(char ch)
 {
     if (ch >= '0' && ch <= '9')
@@ -191,6 +158,10 @@ fromhex(char ch)
     return -1;
 }
 
+/*
+ *  rfc1738_unescape() - Converts escaped characters (%xy numbers) in
+ *  given the string.  %% is a %. %ab is the 8-bit hexadecimal number "ab"
+ */
 void
 rfc1738_unescape(char *s)
 {