]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Move compat/unsafe.h protections from libcompat to source maintenance
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 18 Feb 2014 08:43:02 +0000 (01:43 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 18 Feb 2014 08:43:02 +0000 (01:43 -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 f9d20a8622f8a862421769a9637beadc09ed34a9..a86a93dad01c99aeecdb26886ace6fb5564fdd16 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 4004476265a894cbd4e5097851a9b7f80e91bcb2..c5af5ce42441c934bbb6fbe414ea0d9b2b170fca 100755 (executable)
@@ -94,6 +94,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 ae4c0b70270a6832111db1032ef6890f889853ae..9b279b01fa9440276194f03bc3ff9fa208df2634 100644 (file)
@@ -4525,10 +4525,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) {
@@ -4537,7 +4537,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);