delta: catch error when parsing delta line.
authorYousong Zhou <yszhou4tech@gmail.com>
Mon, 25 May 2015 12:32:41 +0000 (20:32 +0800)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 25 May 2015 21:03:10 +0000 (23:03 +0200)
Reported by sarumpaet [1]

 [1] uci fails to handle long values properly,
     https://github.com/openwrt/packages/issues/1231

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
delta.c

diff --git a/delta.c b/delta.c
index 459d2c7ddfd5d4443c24c02a76952d40319bb871..e9c79ab5be07b80058869b8a4ba69c04cee3de44 100644 (file)
--- a/delta.c
+++ b/delta.c
@@ -293,13 +293,15 @@ static int uci_load_delta_file(struct uci_context *ctx, struct uci_package *p, c
 
        UCI_TRAP_SAVE(ctx, done);
        stream = uci_open_stream(ctx, filename, NULL, SEEK_SET, flush, false);
+       UCI_TRAP_RESTORE(ctx);
+
        if (p)
                changes = uci_parse_delta(ctx, stream, p);
-       UCI_TRAP_RESTORE(ctx);
+
 done:
        if (f)
                *f = stream;
-       else if (stream)
+       else
                uci_close_stream(stream);
        return changes;
 }