Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/string Protect against malloc failure corrupting er...
details: https://anonhg.NetBSD.org/src/rev/8a22093bb043
branches: trunk
changeset: 746227:8a22093bb043
user: kre <kre%NetBSD.org@localhost>
date: Wed Mar 25 16:10:17 2020 +0000
description:
Protect against malloc failure corrupting errno, which is not
permitted of these functions.
diffstat:
lib/libc/string/strerror.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diffs (28 lines):
diff -r 57ff84f0b63d -r 8a22093bb043 lib/libc/string/strerror.c
--- a/lib/libc/string/strerror.c Wed Mar 25 13:07:04 2020 +0000
+++ b/lib/libc/string/strerror.c Wed Mar 25 16:10:17 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: strerror.c,v 1.17 2015/01/20 18:31:25 christos Exp $ */
+/* $NetBSD: strerror.c,v 1.18 2020/03/25 16:10:17 kre Exp $ */
/*
* Copyright (c) 1988 Regents of the University of California.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: strerror.c,v 1.17 2015/01/20 18:31:25 christos Exp $");
+__RCSID("$NetBSD: strerror.c,v 1.18 2020/03/25 16:10:17 kre Exp $");
#define __SETLOCALE_SOURCE__
@@ -78,7 +78,9 @@
thr_once(&strerror_once, strerror_setup);
buf = thr_getspecific(strerror_key);
if (buf == NULL) {
+ error = errno;
buf = malloc(NL_TEXTMAX);
+ errno = error;
if (buf == NULL) {
static char fallback_buf[NL_TEXTMAX];
buf = fallback_buf;
Home |
Main Index |
Thread Index |
Old Index