diff options
author | ache <ache@FreeBSD.org> | 2002-08-09 08:22:29 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2002-08-09 08:22:29 +0000 |
commit | 9d73d0dd122e2ce7df338d16beff65b7bbbc42c5 (patch) | |
tree | ec50b36d8d16a98023a55c6c494ff75a89b994db /lib | |
parent | b11e88aa0eb39e0a14d792aeaf714fbbf091e7eb (diff) | |
download | FreeBSD-src-9d73d0dd122e2ce7df338d16beff65b7bbbc42c5.zip FreeBSD-src-9d73d0dd122e2ce7df338d16beff65b7bbbc42c5.tar.gz |
Add safeguards to never use errno == 0 as setrunelocale() error return code
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/locale/euc.c | 2 | ||||
-rw-r--r-- | lib/libc/locale/rune.c | 4 | ||||
-rw-r--r-- | lib/libc/locale/setrunelocale.c | 6 |
3 files changed, 5 insertions, 7 deletions
diff --git a/lib/libc/locale/euc.c b/lib/libc/locale/euc.c index 43194fa..596d107a 100644 --- a/lib/libc/locale/euc.c +++ b/lib/libc/locale/euc.c @@ -78,7 +78,7 @@ _EUC_init(rl) ++v; if ((ei = malloc(sizeof(_EucInfo))) == NULL) - return (ENOMEM); + return (errno == 0 ? ENOMEM : errno); new__mb_cur_max = 0; for (x = 0; x < 4; ++x) { diff --git a/lib/libc/locale/rune.c b/lib/libc/locale/rune.c index 63a50de..1783cba 100644 --- a/lib/libc/locale/rune.c +++ b/lib/libc/locale/rune.c @@ -70,10 +70,8 @@ _Read_RuneMagi(fp) return (NULL); } - if ((data = malloc(sb.st_size)) == NULL) { - errno = ENOMEM; + if ((data = malloc(sb.st_size)) == NULL) return (NULL); - } errno = 0; rewind(fp); /* Someone might have read the magic number once already */ diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c index f1a01fc..042a06c 100644 --- a/lib/libc/locale/setrunelocale.c +++ b/lib/libc/locale/setrunelocale.c @@ -106,7 +106,7 @@ setrunelocale(char *encoding) return (ENAMETOOLONG); _PathLocale = strdup(p); if (_PathLocale == NULL) - return (ENOMEM); + return (errno == 0 ? ENOMEM : errno); } else _PathLocale = _PATH_LOCALE; } @@ -117,10 +117,10 @@ setrunelocale(char *encoding) (void) strcat(name, "/LC_CTYPE"); if ((fp = fopen(name, "r")) == NULL) - return (errno); + return (errno == 0 ? ENOENT : errno); if ((rl = _Read_RuneMagi(fp)) == NULL) { - saverr = errno; + saverr = (errno == 0 ? EFTYPE : errno); (void)fclose(fp); return (saverr); } |