Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/cgdconfig CID 1340063: fix TOCTOU
details: https://anonhg.NetBSD.org/src/rev/6ab739f48924
branches: trunk
changeset: 341820:6ab739f48924
user: christos <christos%NetBSD.org@localhost>
date: Tue Nov 24 14:07:18 2015 +0000
description:
CID 1340063: fix TOCTOU
diffstat:
sbin/cgdconfig/params.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diffs (37 lines):
diff -r a78bde13f5ff -r 6ab739f48924 sbin/cgdconfig/params.c
--- a/sbin/cgdconfig/params.c Tue Nov 24 08:48:25 2015 +0000
+++ b/sbin/cgdconfig/params.c Tue Nov 24 14:07:18 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: params.c,v 1.27 2015/11/22 20:24:19 christos Exp $ */
+/* $NetBSD: params.c,v 1.28 2015/11/24 14:07:18 christos Exp $ */
/*-
* Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: params.c,v 1.27 2015/11/22 20:24:19 christos Exp $");
+__RCSID("$NetBSD: params.c,v 1.28 2015/11/24 14:07:18 christos Exp $");
#endif
#include <sys/types.h>
@@ -622,15 +622,15 @@
struct params *p;
FILE *f;
char filename[MAXPATHLEN];
- struct stat st;
- if (fn[0] != '/' && stat(fn, &st) == -1 && errno == ENOENT) {
+ if ((f = fopen(fn, "r")) == NULL && fn[0] != '/') {
snprintf(filename, sizeof(filename), "%s/%s",
CGDCONFIG_DIR, fn);
fn = filename;
+ f = fopen(fn, "r");
}
- if ((f = fopen(fn, "r")) == NULL) {
+ if (f == NULL) {
warn("failed to open params file \"%s\"", fn);
return NULL;
}
Home |
Main Index |
Thread Index |
Old Index