Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoconf: Use -std=gnu99 if supported #5600

Merged
merged 2 commits into from
Dec 4, 2024

Conversation

magnumripper
Copy link
Member

@magnumripper magnumripper commented Dec 2, 2024

We first ensure it's supported by the compiler, so this "can't" break anything [famous last words, right?].

Also includes a commit that refactors confusing struct, union and member names for dyna_salt.

If this is merged, it should be after merging #5599 or that one will be included too. Now rebased.

@magnumripper
Copy link
Member Author

magnumripper commented Dec 2, 2024

BTW my testing included on super, which is where I stumbled upon the problem (it has gcc 4.4.7). I will test a few more (on top of build bots compilers and versions).

@magnumripper
Copy link
Member Author

magnumripper commented Dec 2, 2024

clang 16.0.0 "(clang-1600.0.26.4)" new warnings with this (but does accept the gnu99 option, and builds fine)

gpg2john.c:1632:20: warning: passing arguments to a function without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
 1632 |                         (*tag_func[tag])(len, 1, partial, hash);        // first packet (possibly only one if partial is false).
      |                                         ^

@magnumripper
Copy link
Member Author

Just a note

checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
(...)
checking if gcc supports -Wall... yes
checking if gcc supports -std=gnu99... yes
checking if gcc supports -Wno-stringop-truncation... no

That "ISO C89" test seems to be something built-in to autoconf, nothing added to makefiles.

@solardiz
Copy link
Member

solardiz commented Dec 2, 2024

I think this PR is not ready. Let's merge #5599 first, then discuss here.

Anonymous structs/unions is a useful feature, but I've been avoiding it in this tree so far. What uses of it do we currently have?

"dyna_salt_t" was used as struct name, which is backwards. Then "dyna_salt"
was used as typedef name, member name and variable name which was very
confusing. Now using dyna_salt_s, dyna_salt_t and dyna_salt.
Using -std=c99 breaks anonymous structs/unions with gcc-4 (only).

Closes openwall#5595
@magnumripper
Copy link
Member Author

Anonymous structs/unions is a useful feature, but I've been avoiding it in this tree so far. What uses of it do we currently have?

We've had them for over a decade.
The bitfields in dyna_salt.h and all uses of them (many). Sure we can change them but it would make code fugly.
KeePass, for things that were renamed in KDBX4 spec. so unions for readability. Convenient for following the code but not super important now that it works.
slow_hash_plug.c, uaf2john.c and wpapcap2john.c, presumably structs copied from "original" code.

@magnumripper
Copy link
Member Author

I'm not quite sure about dyna_salt: It's either that the bitfield is anonymous, or that the allocation unit is size_t (which we do need), or both.

@magnumripper
Copy link
Member Author

magnumripper commented Dec 3, 2024

From a quick look at wpapcap2john.h it seems the bitfields are not anonymous, but they do use uint16_tas allocation unit - and an odd number of them. Strict standard only allows variations of int. It would be hard to change this.

@magnumripper
Copy link
Member Author

It would be hard to change this.

Looking at the uses of it, maybe not, in that case. We could probably use int for them.

@magnumripper
Copy link
Member Author

magnumripper commented Dec 3, 2024

What is the (specific) reason for us to switch to C99 again? Perhaps we could enable whatever feature is needed - but that would likely be even less portable. Maybe it's mostly things like for (int i; ...).

Also, we could obviously rewrite any such code, but for eg. princeprocessor and mbedtls that would make syncing with upstream much harder.

Copy link
Member

@solardiz solardiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I don't mind gnu99 for now.

@solardiz solardiz changed the title Autoconf: Use --gnu99 if supported Autoconf: Use -std=gnu99 if supported Dec 4, 2024
@solardiz solardiz merged commit b1d063a into openwall:bleeding-jumbo Dec 4, 2024
35 of 36 checks passed
@magnumripper magnumripper deleted the gnu99 branch December 4, 2024 03:38
@solardiz
Copy link
Member

This broke build (or rather the final linking) on our "well" as follows:

dynamic_fmt.o: In function `DynamicFunc__crypt_md5':
/home/solar/j/bleeding-jumbo-20241211/src/dynamic_fmt.c:5274: undefined reference to `MD5_body_for_thread'
dynamic_fmt.o: In function `DynamicFunc__POCrypt':
/home/solar/j/bleeding-jumbo-20241211/src/dynamic_fmt.c:5373: undefined reference to `MD5_body_for_thread'
dynamic_fmt.o: In function `DynamicFunc__crypt2_md5':
/home/solar/j/bleeding-jumbo-20241211/src/dynamic_fmt.c:5416: undefined reference to `MD5_body_for_thread'
dynamic_fmt.o: In function `DynamicFunc__crypt_md5_in1_to_out2':
/home/solar/j/bleeding-jumbo-20241211/src/dynamic_fmt.c:5500: undefined reference to `MD5_body_for_thread'
dynamic_fmt.o: In function `DynamicFunc__crypt_md5_in2_to_out1':
/home/solar/j/bleeding-jumbo-20241211/src/dynamic_fmt.c:5586: undefined reference to `MD5_body_for_thread'
dynamic_fmt.o:/home/solar/j/bleeding-jumbo-20241211/src/dynamic_fmt.c:5674: more undefined references to `MD5_body_for_thread' follow

I've tried adding -std=gnu99 also at link time, but this made no difference. I'll open an issue.

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.

2 participants