aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Zaborski <oshogbo@FreeBSD.org>2021-04-07 19:12:52 +0000
committerMariusz Zaborski <oshogbo@FreeBSD.org>2021-04-07 19:16:37 +0000
commit2b1d0c0087a907fe9944b96c6313711865f9674a (patch)
tree36b90601ac10a10bc5da6012eb50c0d5fad41f46
parent5a8d32b53b919d82d6a3aa9f155bd2a00fb51dc2 (diff)
downloadsrc-2b1d0c0087a907fe9944b96c6313711865f9674a.tar.gz
src-2b1d0c0087a907fe9944b96c6313711865f9674a.zip
fileargs: fix double caching of the same file
In situations when the current file name wasn't the first element on the list we were cleaning the current name too early. This might cause us to pre-cache the same file twice.
-rw-r--r--lib/libcasper/services/cap_fileargs/cap_fileargs.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/libcasper/services/cap_fileargs/cap_fileargs.c b/lib/libcasper/services/cap_fileargs/cap_fileargs.c
index ecab23004fcf..64ec69698165 100644
--- a/lib/libcasper/services/cap_fileargs/cap_fileargs.c
+++ b/lib/libcasper/services/cap_fileargs/cap_fileargs.c
@@ -562,8 +562,12 @@ fileargs_add_cache(nvlist_t *nvlout, const nvlist_t *limits,
break;
}
- if (type != NV_TYPE_NULL || (current_name != NULL &&
- strcmp(fname, current_name) == 0)) {
+ if (type != NV_TYPE_NULL) {
+ i--;
+ continue;
+ }
+ if (current_name != NULL &&
+ strcmp(fname, current_name) == 0) {
current_name = NULL;
i--;
continue;