add an extra check
authorFelix Fietkau <nbd@openwrt.org>
Mon, 28 Jan 2008 02:44:28 +0000 (03:44 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 28 Jan 2008 02:44:28 +0000 (03:44 +0100)
file.c

diff --git a/file.c b/file.c
index 6eaa5ec..4650a96 100644 (file)
--- a/file.c
+++ b/file.c
@@ -567,7 +567,9 @@ int uci_load(struct uci_context *ctx, const char *name, struct uci_package **pac
        if (fd <= 0)
                UCI_THROW(ctx, UCI_ERR_IO);
 
-       flock(fd, LOCK_SH);
+       if (flock(fd, LOCK_SH) < 0)
+               UCI_THROW(ctx, UCI_ERR_IO);
+
        file = fdopen(fd, "r");
        if (!file)
                UCI_THROW(ctx, UCI_ERR_IO);