-
Notifications
You must be signed in to change notification settings - Fork 712
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
libclamav/vba_extract.c: Fix SIGBUS on HP-UX/IA when built as a 64-bit binary #526
Conversation
This doesn't strike me as the best way to fix this (and might even break it). I think the problem really started upstream, in that I'm also concerned that this is breaking indexing into Bottom line, I think the better fix is to simply declare it |
So your suggestion is something like:
|
You'd need to test it on your platform to confirm it resolves the error (since we definitely don't have any HP-UX/IA systems in our test pipelines), but I was thinking something along these lines (to minimize the changed code): void *inflate_data = NULL
char *data = NULL;
...
if ((inflate_data = (data_type_t *)cli_vba_inflate(fd, 0, &data_len)) == NULL) {
cli_dbgmsg("vba_readdir_new: Failed to decompress 'dir'\n");
ret = CL_EARG;
goto done;
}
data = inflate_data;
... I'm thinking that will coax a compatible alignment without additional trickery. |
Did you mean to leave the cast to (data_type_t *)? |
BTW, I compiled vba_extract.c with -Wcast-align on this platform and it gives a warning on any call to le16_to_host() and le32_to_host() where &data[data_offset] is referenced:
|
How about something like this as a solution. Rather than:
we would use:
Less efficient though. |
(Comment based on the current PR content) Doesn't changing the type alter how this would work? &data[data_offset] You'd need to adjust all those macros to adjust the index value. E.g., take this example code: #include <stdio.h>
#include <stdint.h>
int main() {
unsigned char *stuff1 = NULL;
printf("stuff1[1] = %p\n", &stuff1[1]);
uint32_t *stuff2 = NULL;
printf("stuff2[1] = %p\n", &stuff2[1]);
} You get rather different results:
|
We switch to using memcpy() as illustrated in this commit: 2098a84. Hopefully has less issues. |
Use memcpy() to fix alignment issues.
2098a84
to
9770356
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading over this code the latest iteration seems okay to me. I just rebased it with the latest from the main
branch and squashed the commits into one.
If all goes well with the test pipelines I'll merge it.
Sorry this PR sat idle for so very long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing looked good. Only saw expected failures with. Nothing new or unusual.
Fix for issue #525.