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

sha1.c warnings due to inconsistent USE_64_BIT_INT #12

Closed
puetzk opened this issue Feb 20, 2019 · 2 comments
Closed

sha1.c warnings due to inconsistent USE_64_BIT_INT #12

puetzk opened this issue Feb 20, 2019 · 2 comments

Comments

@puetzk
Copy link

puetzk commented Feb 20, 2019

The logic in

print $fh "#ifndef H_PERL\n";
printf $fh "typedef %s U8;\n", $Config{u8type};
printf $fh "#define BYTEORDER 0x%s\n", $Config{byteorder};
print $fh "#endif\n";
seems incorrect (or at least incomplete):

If perl.h has not been included, this defaults to BYTEORDER 0x12345678, which implies a 64-bit swap operation down at

PAR-Packer/myldr/sha1.c.PL

Lines 154 to 166 in 5a98e29

#if BYTEORDER == 0x12345678
#define SWAP_DONE
/* assert(sizeof(PAR_ULONG) == 8); */
for (i = 0; i < 16; i += 2) {
T = *((PAR_ULONG *) dp);
dp += 8;
W[i] = ((T << 24) & 0xff000000) | ((T << 8) & 0x00ff0000) |
((T >> 8) & 0x0000ff00) | ((T >> 24) & 0x000000ff);
T >>= 32;
W[i+1] = ((T << 24) & 0xff000000) | ((T << 8) & 0x00ff0000) |
((T >> 8) & 0x0000ff00) | ((T >> 24) & 0x000000ff);
}
#endif

However, since it does not define U64TYPE or USE_64_BIT_INT, PAR_ULONG is only a 32-bit type:

typedef unsigned long PAR_ULONG; /* 32-or-more-bit quantity */

When building on windows-x86 using strawberryperl 5.28.1, this shows up a warning from gcc

sha1.c:153:4: warning: right shift count >= width of type [-Wshift-count-overflow]
T >>= 32;

But it seems like the real issue isn't really on that line, but up here where BYTEORDER and PAR_ULONG got out of sync. There's a lot of ways this could get fixed, but it seems like the simplest and probably best would be to just #include "config.h" in boot.c before it brings in mktemp.c, so this and main.c would be consistent about which types are used.

@puetzk
Copy link
Author

puetzk commented Feb 20, 2019

caveat: I'm not terribly familar with how the perl headers are laid out, so maybe there's something you should bring in that in turn brings in config.h...

@puetzk puetzk changed the title sha1.c? sha1.c warnings due to inconsistent USE_64_BIT_INT Feb 20, 2019
@rschupp rschupp closed this as completed in 4649979 Mar 2, 2019
@rschupp
Copy link
Owner

rschupp commented Mar 2, 2019

Thanks for spotting!
Can you test with HEAD?

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

No branches or pull requests

2 participants