From 90f6772ff62569482ae9d2281c70a66b345a7c9b Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Fri, 13 Jul 2018 20:51:09 +0200 Subject: [PATCH] Mark function md5() as deprecated and compile md5.c again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quote from issue #15: > libcgi contains an implementation of the md5 hash function, however > its not used inside the library itself and the status regarding > license or potential security issues (despite the weekness of md5 > itself) is not clear. If a user needs md5 he or she could get it from > a specialized library. Although md5 is deprecated (#15) we can not simply remove the code from the API. Do that later. The HAVE_MD5 macro is useless, that was a relict from the old autotools build and actually meant »build with md5«, so we can simply drop the build time generated file and that macro. Fixes: 0643151cf9ee8e09f4a613256bada8cde24b75c4 Signed-off-by: Alexander Dahl --- src/CMakeLists.txt | 7 +------ src/cgi.h | 13 ++++++++++++- src/config.h.cmake.in | 1 - src/md5.c | 4 ---- 4 files changed, 13 insertions(+), 12 deletions(-) delete mode 100644 src/config.h.cmake.in diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5994132..c61d4b1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,11 +2,6 @@ # Copyright 2013,2016,2018 Alexander Dahl # -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/config.h" -) - set(CGI_SRC base64.c cgi.c @@ -14,7 +9,7 @@ set(CGI_SRC error.c general.c list.c - # md5.c + md5.c session.c string.c ) diff --git a/src/cgi.h b/src/cgi.h index 4874a68..f9daccb 100644 --- a/src/cgi.h +++ b/src/cgi.h @@ -23,6 +23,17 @@ #include +#if defined(__GNUC__) +#define CGI_DEPRECATED __attribute__ ((deprecated)) +#elif defined(_MSC_VER) +#define CGI_DEPRECATED __declspec(deprecated) +#elif defined(__clang__) +#define CGI_DEPRECATED __deprecated +#else +#pragma message("WARNING: You need to implement CGI_DEPRECATED for this compiler") +#define CGI_DEPRECATED +#endif + #ifdef __cplusplus extern "C" { #endif @@ -81,7 +92,7 @@ extern char *stripslashes(char *str); extern char *str_base64_encode(char *str); extern char *str_base64_decode(char *str); extern char *recvline(FILE *fp); -extern char *md5(const char *str); +CGI_DEPRECATED extern char *md5(const char *str); extern char *cgi_ltrim(char *str); extern char *cgi_rtrim(char *str); extern char *cgi_trim(char *str); diff --git a/src/config.h.cmake.in b/src/config.h.cmake.in deleted file mode 100644 index 29271cf..0000000 --- a/src/config.h.cmake.in +++ /dev/null @@ -1 +0,0 @@ -#define HAVE_MD5 0 diff --git a/src/md5.c b/src/md5.c index 56cf5c0..a004e15 100644 --- a/src/md5.c +++ b/src/md5.c @@ -23,7 +23,6 @@ #include #include -#include "config.h" #include "error.h" #include "cgi.h" @@ -31,8 +30,6 @@ * @{ */ -#if HAVE_MD5 - #ifndef MD5_H #define MD5_H @@ -95,7 +92,6 @@ char *md5(const char *str) // returning a encrypted string return tmp; } -#endif /*=======================================================================*/