소스 검색

fix null pointer dereference in dcngettext under specific conditions

if setlocale has not been called, the current locale's messages_name
may be a null pointer. the code path where it's assumed to be non-null
was only reachable if bindtextdomain had already been called, which is
normally not done in programs which do not call setlocale, so the
omitted check went unnoticed.

patch from Void Linux, with description rewritten.
Rich Felker 10 년 전
부모
커밋
43e9f652bf
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      src/locale/dcngettext.c

+ 1 - 1
src/locale/dcngettext.c

@@ -132,7 +132,7 @@ char *dcngettext(const char *domainname, const char *msgid1, const char *msgid2,
 	switch (category) {
 	case LC_MESSAGES:
 		locname = loc->messages_name;
-		if (!*locname) goto notrans;
+		if (!locname || !*locname) goto notrans;
 		break;
 	case LC_TIME:
 	case LC_MONETARY: