Date: Wed, 06 Oct 2021 11:31:29 +0200 From: Pablo Correa Gomez <ablocorrea@...mail.com> To: musl@...ts.openwall.com Subject: newlocale: Segmentation fault when locale input is NULL Dear musl maintainers, While doing some work in GNOME control center for postmarketos, we bumped into a segmentation fault which is also present in GNOME in Alpine. After doing some degugging, I figured out that the reason is that, through GNOME desktop, there is a call to newlocale, where they end up calling it with a NULL argument. newlocale(LC_CTYPE, NULL, (locale_t)0); In this case, "name" is passed to __get_locale in src/locale/newlocale.c:27 and then dereferenced in src/locale/locale_map.c:43, causing a segmentation fault. In the case of glibc, this is not an issue, as per the documentation they consider it an error: EINVAL locale is NULL. Unfortunately, this is a difference in the implementation between glibc and musl, maybe due to the fact that the standard in not clear in this point: The newlocale() function may fail if: [EINVAL] The locale argument is not a valid string pointer. My personal believe is that adding a NULL pointer check in musl is very simple and might help not only GNOME desktop, but maybe also other projects in the future. This is the reason why I brought the issue here first instead of directly patching GNOME desktop. If you believe that musl behaviour should remain the way it is, please let me know and I will send MRs for upstream and Alpine's GNOME desktop. I am not subscribed to the mailing list, so I would appreciate if I am CC'ed in any response. Best regards, Pablo Correa Gómez.  https://gitlab.com/postmarketOS/pmaports/-/merge_requests/2552#note_686956660  https://gitlab.gnome.org/GNOME/gnome-desktop  https://man7.org/linux/man-pages/man3/newlocale.3.html  https://pubs.opengroup.org/onlinepubs/9699919799/functions/newlocale.html
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.