From 70b7d73453ed086c1544fce57d7fbe55772daf0a Mon Sep 17 00:00:00 2001 From: Andrew Gunnerson Date: Wed, 7 Feb 2018 21:14:42 -0500 Subject: [PATCH] utils/cpio.c: Fix off-by-one error in cpio_vec_insert Previously, if `cpio_vec_insert()` needed to replace a file and the file already exists as the first entry, then a duplicate entry would get created. This fixes the bug I reported at: https://forum.xda-developers.com/showpost.php?p=75449768&postcount=22647 Signed-off-by: Andrew Gunnerson --- native/jni/utils/cpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/jni/utils/cpio.c b/native/jni/utils/cpio.c index ca766664a..9fe46f182 100644 --- a/native/jni/utils/cpio.c +++ b/native/jni/utils/cpio.c @@ -46,7 +46,7 @@ int cpio_cmp(const void *a, const void *b) { void cpio_vec_insert(struct vector *v, cpio_entry *n) { int i = cpio_find(v, n->filename); - if (i > 0) { + if (i >= 0) { // Replace, then all is done cpio_free(vec_entry(v)[i]); vec_entry(v)[i] = n;