Prevent use-after-free with ctx->ns in set_nameservers(..), which could occur

if the memory wasn't allocated again later on

Reported by: Coverity
Submitted by: Miles Ohlrich <miles.ohlrich@isilon.com>
MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
Enji Cooper 2015-12-22 05:57:23 +00:00
parent 21fddb1173
commit e830a247a1

View File

@ -452,6 +452,7 @@ set_nameservers(struct ctx *ctx, const char *respath, int ns, ...)
free(ctx->ns[i]);
}
free(ctx->ns);
ctx->ns = NULL;
}
fd = open(respath, O_RDWR | O_CREAT | O_NOFOLLOW, 0666);