summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsg <jsg@openbsd.org>2015-02-09 04:27:25 +0000
committerjsg <jsg@openbsd.org>2015-02-09 04:27:25 +0000
commitf09e271f9de1fc9c24bec5b1886a50b6c87b10c6 (patch)
tree86ec59e8775d9a4350b0c3c409aab5b54750d159
parenti missed a quote when cutting the fmt strings up. (diff)
downloadwireguard-openbsd-f09e271f9de1fc9c24bec5b1886a50b6c87b10c6.tar.xz
wireguard-openbsd-f09e271f9de1fc9c24bec5b1886a50b6c87b10c6.zip
fix fd leaks in error paths
ok kettenis@
-rw-r--r--usr.sbin/ldomctl/mdesc.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/usr.sbin/ldomctl/mdesc.c b/usr.sbin/ldomctl/mdesc.c
index c214f6719c0..bba7d9c70ca 100644
--- a/usr.sbin/ldomctl/mdesc.c
+++ b/usr.sbin/ldomctl/mdesc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdesc.c,v 1.7 2012/11/26 20:08:15 kettenis Exp $ */
+/* $OpenBSD: mdesc.c,v 1.8 2015/02/09 04:27:25 jsg Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
@@ -605,17 +605,25 @@ md_read(const char *path)
if (fp == NULL)
return NULL;
- if (fseek(fp, 0, SEEK_END) == -1)
+ if (fseek(fp, 0, SEEK_END) == -1) {
+ fclose(fp);
return NULL;
+ }
size = ftell(fp);
- if (size == -1)
+ if (size == -1) {
+ fclose(fp);
return NULL;
- if (fseek(fp, 0, SEEK_SET) == -1)
+ }
+ if (fseek(fp, 0, SEEK_SET) == -1) {
+ fclose(fp);
return NULL;
+ }
buf = xmalloc(size);
- if (fread(buf, size, 1, fp) != 1)
+ if (fread(buf, size, 1, fp) != 1) {
+ fclose(fp);
return NULL;
+ }
fclose(fp);