diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2020-04-07 21:46:56 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-04-08 10:57:23 +0200 |
commit | 53e5080d9ac5a6af7a6c665abb5c60975bacfe64 (patch) | |
tree | e0c36ef30265ee0426c204aea3297ce36a52255e | |
parent | 61d268764d7a922f086c51e215b6ab10ec28ca74 (diff) |
Avoid using extension of variable length array folded to constant array
(cherry picked from commit 2faefc3b2432409f3ccca0b6ab53a228d5b9b00d)
-rw-r--r-- | src/exclude.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/exclude.c b/src/exclude.c index a599c62..cc5c57a 100644 --- a/src/exclude.c +++ b/src/exclude.c @@ -111,8 +111,7 @@ int has_cachedir_tag(const char *name) { static int path_l = 1024; static char *path = NULL; int l; - const size_t signature_l = sizeof CACHEDIR_TAG_SIGNATURE - 1; - char buf[signature_l]; + char buf[sizeof CACHEDIR_TAG_SIGNATURE - 1]; FILE *f; int match = 0; @@ -131,8 +130,8 @@ int has_cachedir_tag(const char *name) { f = fopen(path, "rb"); if(f != NULL) { - match = ((fread(buf, 1, signature_l, f) == signature_l) && - !memcmp(buf, CACHEDIR_TAG_SIGNATURE, signature_l)); + match = ((fread(buf, 1, sizeof buf, f) == sizeof buf) && + !memcmp(buf, CACHEDIR_TAG_SIGNATURE, sizeof buf)); fclose(f); } return match; |