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

acls: sync type for orig_umask and clear macOS compilation warnings #614

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

carenas
Copy link

@carenas carenas commented May 19, 2024

When sizeof(mode_t) != sizeof(int) it will result in unintentional reads of global memory as shown when running the tests with sanitizers:

==31861==ERROR: AddressSanitizer: global-buffer-overflow on address 0x00010b7e3240 at pc 0x00010b5f192f bp 0x7ff7b4a3d6b0 sp 0x7ff7b4a3d6a8
READ of size 4 at 0x00010b7e3240 thread T0
    #0 0x10b5f192e in default_perms_for_dir acls.c:1093
    #1 0x10b503332 in recv_generator generator.c:1339
    #2 0x10b50d8a9 in generate_files generator.c:2293
    #3 0x10b554ecb in do_recv main.c:1114
    #4 0x10b54ee66 in start_server main.c:1261
    #5 0x10b54e2f3 in child_main main.c:1234
    #6 0x10b605877 in local_child pipe.c:166
    #7 0x10b558a26 in start_client main.c:1577
    #8 0x10b556cce in main main.c:1848
    #9 0x7ff816f15365 in start+0x795 (dyld:x86_64+0xfffffffffff5c365)

0x00010b7e3240 is located 32 bytes before global variable 'sender_keeps_checksum' defined in 'main.c' (0x10b7e3260) of size 4
0x00010b7e3242 is located 0 bytes after global variable 'orig_umask' defined in 'main.c' (0x10b7e3240) of size 2
  'orig_umask' is ascii string ''

While at it, silence again a warning that is being triggered by Apple's Clang 15.

@carenas carenas changed the title acls: sync type for orig_umask and clear macOS warnings acls: sync type for orig_umask and clear macOS compilation warnings May 20, 2024
Since 0527893 (- Call mkdir_defmode() instead of do_mkdir(). - Define
orig_umask in this file, not options.c. - Made orig_umask a mode_t, not an
int., 2006-02-24), the type for the global was changed, and therefore on
systems where sizeof(mode_t) != sizeof(int), writes or reads to them will
overflow to adjacent bytes.

Change the type to the one used everywhere else and avoid this problem.

While at it, silence again a warning that is being triggered by
Apple's clang 15.
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.

1 participant