Module Name: src
Committed By: tnozaki
Date: Wed Aug 8 18:37:26 UTC 2012
Modified Files:
src/lib/libc/locale: rune.c
Log Message:
fix PR lib/46781 statically compiled bash makes locale loading fail.
analyzed and patch provided by enami@ nonaka@ obache@ soda@, thanks.
patch modified by me.
To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/lib/libc/locale/rune.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libc/locale/rune.c
diff -u src/lib/libc/locale/rune.c:1.43 src/lib/libc/locale/rune.c:1.44
--- src/lib/libc/locale/rune.c:1.43 Fri Jan 20 16:31:30 2012
+++ src/lib/libc/locale/rune.c Wed Aug 8 18:37:26 2012
@@ -1,5 +1,3 @@
-/* $NetBSD: rune.c,v 1.43 2012/01/20 16:31:30 joerg Exp $ */
-
/*-
* Copyright (c)2010 Citrus Project,
* All rights reserved.
@@ -162,7 +160,7 @@ _rune_read_file(const char * __restrict
variable_len = be32toh((uint32_t)frl->frl_variable_len);
- n = (len * sizeof(*fre)) + variable_len;
+ n = len * sizeof(*fre);
if (lenvar < n)
return EFTYPE;
lenvar -= n;
@@ -219,15 +217,15 @@ do { \
READ_RANGE(maplower);
READ_RANGE(mapupper);
- memcpy((void *)rune, (void const *)frune, variable_len);
- rl->rl_variable_len = variable_len;
- rl->rl_variable = (void *)rune;
-
- if (lenvar > 0) {
+ if (lenvar < variable_len) {
ret = EFTYPE;
goto err;
}
+ memcpy((void *)rune, (void const *)frune, variable_len);
+ rl->rl_variable_len = variable_len;
+ rl->rl_variable = (void *)rune;
+
_rune_find_codeset(rlp->rlp_codeset, sizeof(rlp->rlp_codeset),
(char *)rl->rl_variable, &rl->rl_variable_len);