From 32466ed51baa6da4be4f7a24db5fa9b9c49d2c92 Mon Sep 17 00:00:00 2001 From: Timothy Qiu Date: Wed, 9 Aug 2017 15:16:24 +0800 Subject: [PATCH] Discards long ACL lines --- src/acl.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/acl.c b/src/acl.c index 5dcc0404..480c829b 100644 --- a/src/acl.c +++ b/src/acl.c @@ -191,6 +191,23 @@ init_acl(const char *path) char buf[257]; while (!feof(f)) if (fgets(buf, 256, f)) { + // Discards the whole line if longer than 255 characters + int long_line = 0; // 1: Long 2: Error + while ((strlen(buf) == 255) && (buf[254] != '\n')) { + long_line = 1; + LOGE("Discarding long ACL content: %s", buf); + if (fgets(buf, 256, f) == NULL) { + long_line = 2; + break; + } + } + if (long_line) { + if (long_line == 1) { + LOGE("Discarding long ACL content: %s", buf); + } + continue; + } + // Trim the newline int len = strlen(buf); if (len > 0 && buf[len - 1] == '\n') {