config rewrite failed save errno in case of being tainted
errno would be potentially tainted during the serverLog() by the file io functions, such as fopen and fflush.
@@ -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);
