config rewrite failed save errno in case of being tainted (#10461)

errno would be potentially tainted during the serverLog() by the file io functions, such as fopen and fflush.
This commit is contained in:
郭伟光 2022-03-21 20:20:23 +08:00 committed by GitHub
parent 4517fadb59
commit 93dda65354
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3033,8 +3033,10 @@ void configRewriteCommand(client *c) {
return;
}
if (rewriteConfig(server.configfile, 0) == -1) {
serverLog(LL_WARNING,"CONFIG REWRITE failed: %s", strerror(errno));
addReplyErrorFormat(c,"Rewriting config file: %s", strerror(errno));
/* save errno in case of being tainted. */
int err = errno;
serverLog(LL_WARNING,"CONFIG REWRITE failed: %s", strerror(err));
addReplyErrorFormat(c,"Rewriting config file: %s", strerror(err));
} else {
serverLog(LL_WARNING,"CONFIG REWRITE executed with success.");
addReply(c,shared.ok);