]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Move compat/unsafe.h protections from libcompat to source maintenance
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 8 Feb 2014 12:33:31 +0000 (05:33 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 8 Feb 2014 12:33:31 +0000 (05:33 -0700)
It is sufficient to run a code scan from source-maintenance.sh for the
unsafe functions being used in Squid-specific code instead of
hard-coding compiler breakage on users.
This also "fixes" reporting of errors when cstdio pulls in use of the
unsafe functions by stdlib.

compat/Makefile.am
compat/compat.h
compat/unsafe.h [deleted file]
scripts/source-maintenance.sh
src/cache_cf.cc

index 22ffcf8cddc058bc76554330b87a0161c8bb1b19..70cf427ad57524b9bfaeab47264c50e38ab6092e 100644 (file)
@@ -45,7 +45,6 @@ libcompat_squid_la_SOURCES = \
        strnrchr.c \
        tempnam.h \
        types.h \
-       unsafe.h \
        valgrind.h \
        xalloc.cc \
        xalloc.h \
index 54720192bf0d18115dbc00a26621d34c4d5bb881..ee2d231af73f3f8660a23da90cc8b9c624845d49 100644 (file)
  */
 #include "compat/GnuRegex.h"
 
-/* some functions are unsafe to be used in Squid. */
-#include "compat/unsafe.h"
-
 /* cppunit is not quite C++0x compatible yet */
 #include "compat/cppunit.h"
 
diff --git a/compat/unsafe.h b/compat/unsafe.h
deleted file mode 100644 (file)
index d58f546..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef _SQUID_COMPAT_UNSAFE_H
-#define _SQUID_COMPAT_UNSAFE_H
-
-/*
- * Trap unintentional use of functions unsafe for use within squid.
- */
-
-#if !SQUID_NO_STRING_BUFFER_PROTECT
-#ifndef sprintf
-#define sprintf ERROR_sprintf_UNSAFE_IN_SQUID
-#endif
-#ifndef strdup
-#define strdup ERROR_strdup_UNSAFE_IN_SQUID
-#endif
-#endif /* SQUID_NO_STRING_BUFFER_PROTECT */
-
-#endif /* _SQUID_COMPAT_UNSAFE_H */
index 0ecb756d986dcd214ef3a3a187e9073edd0b2584..72c250a00bb4f3344d091c28cd1fa6d256d2d9ce 100755 (executable)
@@ -105,6 +105,19 @@ for FILENAME in `ls -1`; do
                echo "ERROR: ${PWD}/${FILENAME} contains reference to forward.h without path"
        fi
 
+       #
+       # detect functions unsafe for use within Squid.
+       # strdup()
+       #
+       STRDUP=`grep -e "[^x]strdup" ${FILENAME}`;
+       if test "x${STRDUP}" != "x" ; then
+               echo "ERROR: ${PWD}/${FILENAME} contains unprotected use of strdup()"
+       fi
+       SPRINTF=`grep -e "[^v]sprintf" ${FILENAME}`;
+       if test "x${SPRINTF}" != "x" ; then
+               echo "ERROR: ${PWD}/${FILENAME} contains unsafe use of sprintf()"
+       fi
+
        #
        # DEBUG Section list maintenance
        #
index 95fcd154d768989c3c76195b1676daf7cfb4a2fc..6224a44697096e714f6fb2748352eefb91420cfa 100644 (file)
@@ -4499,10 +4499,10 @@ static void parse_sslproxy_cert_adapt(sslproxy_cert_adapt **cert_adapt)
 
     if (strcmp(al, Ssl::CertAdaptAlgorithmStr[Ssl::algSetValidAfter]) == 0) {
         ca->alg = Ssl::algSetValidAfter;
-        ca->param = strdup("on");
+        ca->param = xstrdup("on");
     } else if (strcmp(al, Ssl::CertAdaptAlgorithmStr[Ssl::algSetValidBefore]) == 0) {
         ca->alg = Ssl::algSetValidBefore;
-        ca->param = strdup("on");
+        ca->param = xstrdup("on");
     } else if (strcmp(al, Ssl::CertAdaptAlgorithmStr[Ssl::algSetCommonName]) == 0) {
         ca->alg = Ssl::algSetCommonName;
         if (param) {
@@ -4511,7 +4511,7 @@ static void parse_sslproxy_cert_adapt(sslproxy_cert_adapt **cert_adapt)
                 self_destruct();
                 return;
             }
-            ca->param = strdup(param);
+            ca->param = xstrdup(param);
         }
     } else {
         debugs(3, DBG_CRITICAL, "FATAL: sslproxy_cert_adapt: unknown cert adaptation algorithm: " << al);