diff --git a/debian/changelog b/debian/changelog index 58b6ce6..b03d2f8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,14 @@ * A symbols file for libhdate1. * typo_output.patch: fix a typo "ouput" (Lintian). * Bump standards version: 3.9.4. + * cflags.patch: pass along build-flags set by deb-helpers. + * As a result of building with warnings and hardening, several other + fixes: + - missing_format.patch - missing a format string for fprintf. + - duplicate_gnu_source.patch - _GNU_SOURCE was set both in autoconf + and in files. + - nested_extern.patch - Don't #include files inside a function. + - size_t.patch - int vs. size_t issues. -- Tzafrir Cohen Thu, 01 Nov 2012 16:53:34 +0200 diff --git a/debian/patches/cflags.patch b/debian/patches/cflags.patch new file mode 100644 index 0000000..ca18aed --- /dev/null +++ b/debian/patches/cflags.patch @@ -0,0 +1,82 @@ +Description: Pass variables set by Debian build system +Author: Tzafrir Cohen + +The Debian build system sets several variables (LDFLAGS, CFLAGS, +CPPFLAGS). + +* CFLAGS was overriden by the configure script. +* The perl and python bindings were not using the values of those + variables. + +--- a/configure.in ++++ b/configure.in +@@ -33,7 +33,6 @@ AC_C_CONST + AC_CONFIG_MACRO_DIR([m4]) + AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + +-CFLAGS= + LIBS=-lm + + dnl ======================================================================================= +--- a/configure ++++ b/configure +@@ -12466,7 +12466,6 @@ fi + + + +-CFLAGS= + LIBS=-lm + + +--- a/bindings/perl/Makefile.am ++++ b/bindings/perl/Makefile.am +@@ -11,8 +11,8 @@ all-am: hdate.so + + + hdate.so: hdate_wrap.cxx +- g++ -fpic -c hdate_wrap.cxx $(PE_CFLAGS) -I$(top_srcdir)/src +- g++ -shared hdate_wrap.o ../../src/.libs/libhdate.so -o hdate.so ++ g++ -fpic -c hdate_wrap.cxx $(CFLAGS) $(CPPFLAGS) $(PE_CFLAGS) -I$(top_srcdir)/src ++ g++ -shared hdate_wrap.o ../../src/.libs/libhdate.so -o hdate.so $(LDFLAGS) + + hdate_wrap.cxx: hdate.i + swig -perl -c++ hdate.i +--- a/bindings/perl/Makefile.in ++++ b/bindings/perl/Makefile.in +@@ -402,8 +402,8 @@ uninstall-am: + @WITH_PERL_TRUE@all-am: hdate.so + + @WITH_PERL_TRUE@hdate.so: hdate_wrap.cxx +-@WITH_PERL_TRUE@ g++ -fpic -c hdate_wrap.cxx $(PE_CFLAGS) -I$(top_srcdir)/src +-@WITH_PERL_TRUE@ g++ -shared hdate_wrap.o ../../src/.libs/libhdate.so -o hdate.so ++@WITH_PERL_TRUE@ g++ -fpic -c hdate_wrap.cxx $(CFLAGS) $(CPPFLAGS) $(PE_CFLAGS) -I$(top_srcdir)/src ++@WITH_PERL_TRUE@ g++ -shared hdate_wrap.o ../../src/.libs/libhdate.so -o hdate.so $(LDFLAGS) + + @WITH_PERL_TRUE@hdate_wrap.cxx: hdate.i + @WITH_PERL_TRUE@ swig -perl -c++ hdate.i +--- a/bindings/python/Makefile.am ++++ b/bindings/python/Makefile.am +@@ -11,8 +11,8 @@ all-am: _hdate.so + + + _hdate.so: hdate_wrap.cxx +- g++ -fpic -c hdate_wrap.cxx $(PY_CFLAGS) -I$(top_srcdir)/src +- g++ -shared hdate_wrap.o ../../src/.libs/libhdate.so -o _hdate.so ++ g++ -fpic -c hdate_wrap.cxx $(CPPFLAGS) $(CFLAGS) $(PY_CFLAGS) -I$(top_srcdir)/src ++ g++ -shared hdate_wrap.o ../../src/.libs/libhdate.so -o _hdate.so $(LDFLAGS) + + hdate_wrap.cxx: hdate.i + swig -python -c++ hdate.i +--- a/bindings/python/Makefile.in ++++ b/bindings/python/Makefile.in +@@ -402,8 +402,8 @@ uninstall-am: + @WITH_PYTHON_TRUE@all-am: _hdate.so + + @WITH_PYTHON_TRUE@_hdate.so: hdate_wrap.cxx +-@WITH_PYTHON_TRUE@ g++ -fpic -c hdate_wrap.cxx $(PY_CFLAGS) -I$(top_srcdir)/src +-@WITH_PYTHON_TRUE@ g++ -shared hdate_wrap.o ../../src/.libs/libhdate.so -o _hdate.so ++@WITH_PYTHON_TRUE@ g++ -fpic -c hdate_wrap.cxx $(CPPFLAGS) $(CFLAGS) $(PY_CFLAGS) -I$(top_srcdir)/src ++@WITH_PYTHON_TRUE@ g++ -shared hdate_wrap.o ../../src/.libs/libhdate.so -o _hdate.so $(LDFLAGS) + + @WITH_PYTHON_TRUE@hdate_wrap.cxx: hdate.i + @WITH_PYTHON_TRUE@ swig -python -c++ hdate.i diff --git a/debian/patches/duplicate_gnu_source.patch b/debian/patches/duplicate_gnu_source.patch new file mode 100644 index 0000000..40e4dce --- /dev/null +++ b/debian/patches/duplicate_gnu_source.patch @@ -0,0 +1,53 @@ +Description: _GNU_SOURCE is already set in autoconf. +Author: Tzafrir Cohen + +--- a/examples/hcal/hdate.c ++++ b/examples/hcal/hdate.c +@@ -20,7 +20,6 @@ + * along with this program. If not, see . + */ + +-#define _GNU_SOURCE // For mempcpy, asprintf + #include // For hebrew date + //#include "../../src/hdate.h" + #include // For atoi, getenv, setenv +--- a/examples/hcal/local_functions.c ++++ b/examples/hcal/local_functions.c +@@ -25,7 +25,6 @@ + /************************************************** + * functions to support hcal and hdate + **************************************************/ +-#define _GNU_SOURCE // For mempcpy, asprintf + + #include // For hebrew date + //include "../../src/hdate.h" +--- a/examples/hcal/hcal.c ++++ b/examples/hcal/hcal.c +@@ -20,7 +20,6 @@ + * along with this program. If not, see . + */ + +-#define _GNU_SOURCE // for mempcpy + #include // For printf + #include // For hebrew date + //#include "../../src/hdate.h" +--- a/src/deprecated.c ++++ b/src/deprecated.c +@@ -16,7 +16,6 @@ + * along with this program. If not, see . + */ + +-#define _GNU_SOURCE + #include + #include + #include +--- a/src/hdate_strings.c ++++ b/src/hdate_strings.c +@@ -18,7 +18,6 @@ + * along with this program. If not, see . + */ + +-#define _GNU_SOURCE + #include + #include + #include diff --git a/debian/patches/missing_format.patch b/debian/patches/missing_format.patch new file mode 100644 index 0000000..2bb0dd1 --- /dev/null +++ b/debian/patches/missing_format.patch @@ -0,0 +1,17 @@ +Description: Use an explicit format string when printing config file +Author: Tzafrir Cohen + +The call to print the default configuration text to the configuration file +should use an explicit "%s". However the text comes from the code and does +not happen to contain any '%' sign, so it is not explitable. +--- a/examples/hcal/local_functions.c ++++ b/examples/hcal/local_functions.c +@@ -676,7 +676,7 @@ FILE* get_config_file( const char* confi + error(0, errno, "%s: %s", N_("failure attempting to create config file"), config_file_path); + return; + } +- fprintf(config_file, default_config_file_text); ++ fprintf(config_file, "%s", default_config_file_text); + error(0,0,"%s: %s",N_("config file created"), config_file_path); + if (fclose(config_file) != 0) error(0,errno,"%s %s",N_("failure closing"),config_file_name); + } diff --git a/debian/patches/nested_extern.patch b/debian/patches/nested_extern.patch new file mode 100644 index 0000000..0d4e7cc --- /dev/null +++ b/debian/patches/nested_extern.patch @@ -0,0 +1,31 @@ +Description: Do not include headers inside a function. +Author: Tzafrir Cohen + +If you #include unistd.h inside a function, the declerations made in it +can be considered nested functions. +--- a/examples/hcal/local_functions.c ++++ b/examples/hcal/local_functions.c +@@ -641,6 +641,11 @@ file. Attempting to create a config file + } + + ++#include // for get pwuid ++#include // for getuid ++#include ++#include // for mkdir, ++ + /************************************************************ + * Open config file, or create one + * - returns filepointer or NULL +@@ -650,11 +655,6 @@ FILE* get_config_file( const char* confi + const char* config_file_name, + const char* default_config_file_text ) + { +-#include // for get pwuid +-#include // for getuid +-#include +-#include // for mkdir, +- + size_t path_len; + + char* config_home_path_name = ""; diff --git a/debian/patches/series b/debian/patches/series index 8d920e4..8502cf2 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -4,3 +4,8 @@ fix_3 time_t.patch typo_output.patch +cflags.patch +duplicate_gnu_source.patch +size_t.patch +nested_extern.patch +missing_format.patch diff --git a/debian/patches/size_t.patch b/debian/patches/size_t.patch new file mode 100644 index 0000000..b4a7e3d --- /dev/null +++ b/debian/patches/size_t.patch @@ -0,0 +1,47 @@ +Description: size_t vars need %d in printf. %*s needs int +Author: Tzafrir Cohen +--- a/examples/hcal/local_functions.c ++++ b/examples/hcal/local_functions.c +@@ -247,11 +247,11 @@ void revstr( char *source, const size_t + + #define DEBUG 0 + #if DEBUG +-printf("\nrevstr: entry: sourcelen = %d, source = %s\n",source_len, source); ++printf("\nrevstr: entry: sourcelen = %zd, source = %s\n",source_len, source); + #endif + + if (source == NULL) {error(0,0,"revstr: source buffer pointer is NULL"); exit(0);}; +- if (source_len <= 0) {error(0,0,"revstr: source_len parameter invalid, %d",source_len); exit(0);}; ++ if (source_len <= 0) {error(0,0,"revstr: source_len parameter invalid, %zd",source_len); exit(0);}; + + size_t i,j; + char *temp_buff; +@@ -272,7 +272,7 @@ printf("\nrevstr: entry: sourcelen = %d, + memcpy(source, temp_buff, source_len); + source[source_len] = '\0'; + #if DEBUG +-printf("\nrevstr: before free(tempbuff): sourcelen = %d, source = %s\n",source_len, source); ++printf("\nrevstr: before free(tempbuff): sourcelen = %zd, source = %s\n",source_len, source); + #endif + free(temp_buff); + return; +--- a/examples/hcal/hcal.c ++++ b/examples/hcal/hcal.c +@@ -1135,7 +1135,7 @@ void print_week( int jd, const int month + // padding - FIXME - spaces are single-byte, while + // the Hebrew characters are two bytes + const int margin_max = 15; +- printf("%*s%s", (margin_max - shabbat_name_str_len/2)," ", shabbat_name_buffer); ++ printf("%*s%s", (int) (margin_max - shabbat_name_str_len/2)," ", shabbat_name_buffer); + + free(shabbat_name_buffer); + } +@@ -1344,7 +1344,7 @@ int print_month ( const int month, const + // padding - FIXME - spaces are single-byte, while + // the Hebrew characters are two bytes + const int margin_max = 16; // 15 fails because of jabotinsky in july +- printf("%*s%s\n", (margin_max - holiday_str_len/2)," ", holiday_buffer); ++ printf("%*s%s\n", (int) (margin_max - holiday_str_len/2)," ", holiday_buffer); + + free(holiday_buffer); + }