Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/string wcsdup(3): use reallocarr to catch integer o...
details: https://anonhg.NetBSD.org/src/rev/4fd193e7fed7
branches: trunk
changeset: 1024574:4fd193e7fed7
user: nia <nia%NetBSD.org@localhost>
date: Fri Oct 29 10:11:57 2021 +0000
description:
wcsdup(3): use reallocarr to catch integer overflow
diffstat:
lib/libc/string/wcsdup.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diffs (30 lines):
diff -r 684ee719219a -r 4fd193e7fed7 lib/libc/string/wcsdup.c
--- a/lib/libc/string/wcsdup.c Fri Oct 29 07:55:04 2021 +0000
+++ b/lib/libc/string/wcsdup.c Fri Oct 29 10:11:57 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wcsdup.c,v 1.3 2008/05/26 13:17:48 haad Exp $ */
+/* $NetBSD: wcsdup.c,v 1.4 2021/10/29 10:11:57 nia Exp $ */
/*
* Copyright (C) 2006 Aleksey Cheusov
@@ -14,7 +14,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcsdup.c,v 1.3 2008/05/26 13:17:48 haad Exp $");
+__RCSID("$NetBSD: wcsdup.c,v 1.4 2021/10/29 10:11:57 nia Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -33,9 +33,9 @@
_DIAGASSERT(str != NULL);
len = wcslen(str) + 1;
- copy = malloc(len * sizeof (wchar_t));
- if (!copy)
+ copy = NULL;
+ if (reallocarr(©, len, sizeof(wchar_t)) != 0)
return NULL;
return wmemcpy(copy, str, len);
Home |
Main Index |
Thread Index |
Old Index