Skip to content
Snippets Groups Projects
Commit f3205b59 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix duplicate data in cacheinfo file

Since the cache file is opened for append, truncate it before calling
iniWriteFile().  This isn't create because if it fails, it will
leave the file empty, which will cause the next time this function
is called to do a full request, but at least if fails safe.
parent a6a2acd4
Branches
Tags
No related merge requests found
Pipeline #8011 passed
......@@ -759,7 +759,16 @@ write_cacheinfo(struct http_session *sess)
if (!iniSetBool(&info, NULL, "Immutable", sess->cache.immutable, NULL))
goto error_return;
}
bool ret = iniWriteFile(sess->cache_info, info);
fflush(sess->cache_info);
bool ret;
if (chsize(fileno(sess->cache_info), 0) != 0) {
fseek(sess->cache_info, 0, SEEK_SET);
ret = false;
}
else {
fseek(sess->cache_info, 0, SEEK_SET);
ret = iniWriteFile(sess->cache_info, info);
}
fclose(sess->cache_info);
sess->cache_info = NULL;
strListFree(&info);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment