diff options
author | Yousong Zhou <yszhou4tech@gmail.com> | 2014-12-16 15:00:06 +0800 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-12-18 12:38:15 +0100 |
commit | def58eba24cc53f8761903145fef8db65e6e4760 (patch) | |
tree | 914519e5b86233bbcaf9eadc10d694489608486e | |
parent | 61657246a9145e7f9e8780f69e0e198231345deb (diff) | |
download | uci-def58eba24cc53f8761903145fef8db65e6e4760.tar.gz |
file: fix EOF check.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
-rw-r--r-- | file.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -48,8 +48,8 @@ __private void uci_getln(struct uci_context *ctx, int offset) pctx->buf = uci_malloc(ctx, LINEBUF); pctx->bufsz = LINEBUF; } - /* `offset' may off by one */ - if (offset >= pctx->bufsz) { + /* It takes 2 slots for fgets to read 1 char. */ + if (offset >= pctx->bufsz - 1) { pctx->bufsz *= 2; pctx->buf = uci_realloc(ctx, pctx->buf, pctx->bufsz); } |