Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libwrap There's no point setting errno, it is just overw...
details: https://anonhg.NetBSD.org/src/rev/164a51c7a9fc
branches: trunk
changeset: 448155:164a51c7a9fc
user: kre <kre%NetBSD.org@localhost>
date: Wed Jan 23 02:32:06 2019 +0000
description:
There's no point setting errno, it is just overwritten by err
in the exit path ... this function never fails, it simply sometimes
doesn't actually expand the %m and just leaves the format string
intact.
And declare variables at the head of their scope, not at some random
place in the middle of the code, whatever C allows, that is just ugly.
diffstat:
lib/libwrap/expandm.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
diffs (44 lines):
diff -r 87b7cb7a2bcd -r 164a51c7a9fc lib/libwrap/expandm.c
--- a/lib/libwrap/expandm.c Wed Jan 23 02:00:00 2019 +0000
+++ b/lib/libwrap/expandm.c Wed Jan 23 02:32:06 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: expandm.c,v 1.9 2019/01/23 02:00:00 christos Exp $ */
+/* $NetBSD: expandm.c,v 1.10 2019/01/23 02:32:06 kre Exp $ */
/*-
* Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: expandm.c,v 1.9 2019/01/23 02:00:00 christos Exp $");
+__RCSID("$NetBSD: expandm.c,v 1.10 2019/01/23 02:32:06 kre Exp $");
#include <limits.h>
#include <stdio.h>
@@ -56,11 +56,12 @@
buf = NULL;
for (ptr = fmt; (m = strstr(ptr, "%m")) != NULL; ptr = m + 2) {
size_t cnt = 0;
+ size_t nlen;
for (char *p = m; p >= ptr && *p == '%'; p--)
cnt++;
- size_t nlen = (size_t)(m - ptr);
+ nlen = (size_t)(m - ptr);
/*
* we can't exceed INT_MAX because int is used as
* a format width
@@ -73,10 +74,8 @@
* We can't exceed PTRDIFF_MAX because we would
* not be able to address the pointers
*/
- if (tlen >= PTRDIFF_MAX) {
- errno = EINVAL;
+ if (tlen >= PTRDIFF_MAX)
goto out;
- }
nbuf = realloc(buf, tlen + 1);
if (nbuf == NULL)
Home |
Main Index |
Thread Index |
Old Index