Repository navigation
Make the build warning-free with GCC 15 + glibc C23 string headers (fixes #6041) - #6059
Open
Shanmukh-l33t wants to merge 1 commit into
Open
Shanmukh-l33t wants to merge 1 commit into
Shanmukh-l33t wants to merge 1 commit into
Conversation
Twelve sites stored the result of strchr/strrchr/strstr applied to a const-qualified pointer into a char *. glibc 2.40+ provides const-returning overloads for those functions under __GLIBC_USE(ISOC23), which our -D_GNU_SOURCE enables even when compiling with -std=gnu99, so GCC 15 reports -Wdiscarded-qualifiers at all of them while older toolchains stay silent. Declare the walkers const where they are only read, search the mutable static Buf directly in dynamic_expr_normalize(), reuse the existing const cp2 for the colon scan in do_compile(), and cast explicitly only where the code genuinely writes through the pointer (link_funcs() mutation and the comp_optimize_expression() pExpr walk). encoding_data.h: the four comment dumps embed raw U+200E/U+200F (the CP1255/CP1256 tables really do map bytes to them); textualize those as <U+200E>/<U+200F> so -Wbidi-chars is quiet. The tables and every other byte are untouched. Reported in openwall#6041: the reported build goes from 38 warnings to 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6041
Problem
Building
bleeding-jumbowith GCC 15 on Ubuntu 26.04 produces 38 warnings: 13-Wdiscarded-qualifiers, 24 bidi-comment warnings, and one libbz2#warning(environmental).Root cause
The
-Wdiscarded-qualifiersset is not generic sloppiness in john's code — it needs glibc ≥ 2.40's C23 const-genericstrchr/strstr/strrchroverloads (string.hgates them on__GLIBC_USE(ISOC23), which john's own-D_GNU_SOURCECFLAGS turns on even under-std=gnu99, plus__glibc_const_genericfrommisc/sys/cdefs.h). On older glibc (this host: 2.39) the same tree builds warning-free, which is why the warnings never showed up before.Reproduction (RED)
I reproduced the reporter's exact warning set by force-including glibc HEAD's
string.h/features.hand__glibc_const_generic, built with GCC 15.2 (the reporter's compiler):encoding_data.h, 1 libbz2#warning; matches the issue line-for-line (plusSIPdump.h:335, which the reporter's libpcap-less build skips)Changes
conston the walkers that only read (formats.c,loader.c,mask.c,sunmd5,hccap2john,wpapcap2john,SIPdump.h,find_the_extra_params)dynamic_expr_normalizesearches the mutableBufit just filled rather than re-qualifying aconst char *do_compile's colon scan reuses the existingconst char *cp2(char *)casts only where the code genuinely writes through the pointer (link_funcsdoes*cp++ = 0;comp_optimize'spis amemcpydestination — aconstthere broke the build and was reverted in favor of the cast)encoding_data.h: raw U+200E/U+200F characters inside four comment dumps written as<U+200E>/<U+200F>text (the CP1255/CP1256 tables genuinely map to them and are untouched)Testing
git show --check: clean (matches CI's whitespace job)./run/john --test=1: all 439 formats benchmarked, 0 failures--list=formats,--test=1 --format='dynamic=md5($p)',--test=1 --format='raw-md*'(wildcard →wild_cmp/fmt_match),--test=1 --format=SunMD5(getrounds), mask crack[1][2][3][4]on a known hash (mask_len bracket branch), converter usage runs — all exit 0