Skip to content
Snippets Groups Projects
Commit c782080e authored by Daniel Salzman's avatar Daniel Salzman
Browse files

zonefile: fix passing NULL argument (clang analyzer)

parent b07dd6e0
No related branches found
No related tags found
No related merge requests found
......@@ -329,16 +329,25 @@ static int open_tmp_filename(const char *old_name, char **new_name)
{
*new_name = sprintf_alloc("%s.XXXXXX", old_name);
if (*new_name == NULL) {
return -1;
goto open_tmp_failed;
}
int fd = mkstemp(*new_name);
if (fd < 0 || fchmod(fd, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) != 0) {
free(*new_name);
*new_name = NULL;
if (fd < 0) {
goto open_tmp_failed;
}
if (fchmod(fd, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) != 0) {
close(fd);
goto open_tmp_failed;
}
return fd;
open_tmp_failed:
free(*new_name);
*new_name = NULL;
return -1;
}
/*! \brief Prepare a directory for the file. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment