Skip to content

Make the build warning-free with GCC 15 + glibc C23 string headers (fixes #6041) - #6059

Open
Shanmukh-l33t wants to merge 1 commit into
openwall:bleeding-jumbofrom
Shanmukh-l33t:fix-6041-build-warnings
Open

Shanmukh-l33t wants to merge 1 commit into
openwall:bleeding-jumbofrom
Shanmukh-l33t:fix-6041-build-warnings

Conversation

@Shanmukh-l33t

Copy link
Copy Markdown

Fixes #6041

Problem

Building bleeding-jumbo with 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-qualifiers set is not generic sloppiness in john's code — it needs glibc ≥ 2.40's C23 const-generic strchr/strstr/strrchr overloads (string.h gates them on __GLIBC_USE(ISOC23), which john's own -D_GNU_SOURCE CFLAGS turns on even under -std=gnu99, plus __glibc_const_generic from misc/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.h and __glibc_const_generic, built with GCC 15.2 (the reporter's compiler):

  • before the fix: 38 warnings — 13 discarded-qualifiers (formats.c, loader.c, mask.c, sunmd5, hccap2john/wpapcap2john, SIPdump.h, find_the_extra_params, dynamic_expr_normalize, do_compile), 24 bidi-mark warnings in encoding_data.h, 1 libbz2 #warning; matches the issue line-for-line (plus SIPdump.h:335, which the reporter's libpcap-less build skips)
  • after the fix: 0 warnings under the same config
  • stock gcc-13 build on stock glibc: 0 warnings before and after

Changes

  • const on the walkers that only read (formats.c, loader.c, mask.c, sunmd5, hccap2john, wpapcap2john, SIPdump.h, find_the_extra_params)
  • dynamic_expr_normalize searches the mutable Buf it just filled rather than re-qualifying a const char *
  • do_compile's colon scan reuses the existing const char *cp2
  • explicit (char *) casts only where the code genuinely writes through the pointer (link_funcs does *cp++ = 0; comp_optimize's p is a memcpy destination — a const there 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

  • reproducing config (GCC 15.2 + glibc HEAD headers): 0 warnings; stock gcc-13 build: 0 warnings
  • git show --check: clean (matches CI's whitespace job)
  • full ./run/john --test=1: all 439 formats benchmarked, 0 failures
  • targeted runtime: --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
  • no PR template and no CLA bot in this repository; nothing in the diff changes format behavior — only types, comments, and one scan pointer's qualifier

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build warnings on Ubuntu 26.04

1 participant