build: Pikaur-safe hardening flags, opt-in sanitizers, -Wsign-compare
Re-introduce the build hardening that5459e78e8attempted, in a form that coexists with Arch/Pikaur builds (the conflict that forced its revert in0722dc9e3). configure.ac: - Add -D_FORTIFY_SOURCE=2 only when neither $CFLAGS nor $CPPFLAGS already define _FORTIFY_SOURCE (makepkg injects its own) and not under --coverage. - Route glib/gio CFLAGS through -isystem so their macros don't trip our -W set. - Add --enable-sanitizers (ASan + UBSan; unsigned-integer-overflow probed, skipped on gcc) for a dedicated CI job, off by default. - Add --enable-hardening to gate -Wnull-dereference (false positives under -O2 on some toolchains), off by default. - Promote -Wsign-compare from -Wno- to an active probed warning. Also fix the sign-conversion sites that -Wsign-compare/-Wconversion cleanup surfaced as safe (pointer-diff to gsize via new g_diff_to_gsize helper, non-negative int casts), and validate the /vcard remove index through strtoi_range so a negative argument can no longer become a huge unsigned index. Refs #112
This commit is contained in:
@@ -158,6 +158,14 @@ gboolean create_dir(const char* name);
|
||||
gboolean copy_file(const char* const src, const char* const target, const gboolean overwrite_existing);
|
||||
char* str_replace(const char* string, const char* substr, const char* replacement);
|
||||
gboolean strtoi_range(const char* str, int* saveptr, int min, int max, char** err_msg);
|
||||
|
||||
// Pointer-diff to gsize for callers that know end >= start by construction.
|
||||
static inline gsize
|
||||
g_diff_to_gsize(const void* end, const void* start)
|
||||
{
|
||||
g_assert(end >= start);
|
||||
return (gsize)((const char*)end - (const char*)start);
|
||||
}
|
||||
int utf8_display_len(const char* const str);
|
||||
gchar* str_xml_sanitize(const char* const str);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user