[git commit branch/0.9.33] locale: avoid segfault freelocale()

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Thu Apr 26 20:37:29 UTC 2012


commit: http://git.uclibc.org/uClibc/commit/?id=3902d0c47212193778225e5f5e8257f5584f3061
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/0.9.33

PR 4964

Eric Nadler writes:
It looks to me like the base structure is not fully initialized
with 0 (only a subset of the structure is initialized).
This later results in a free of base->collate.index2weight in
_locale_set_l.
This free tries to free uninitialized memory and segfaults.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 libc/misc/locale/locale.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c
index 40303ab..e8fddf6 100644
--- a/libc/misc/locale/locale.c
+++ b/libc/misc/locale/locale.c
@@ -1292,7 +1292,7 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
 	}
 #else
 	if (!base) {
-		base = malloc(sizeof(struct __uclibc_locale_struct));
+		base = calloc(1, sizeof(struct __uclibc_locale_struct));
 		if (base == NULL)
 			return base;
 		_locale_init_l(base);


More information about the uClibc-cvs mailing list