Introduce fmkostemp_safe and use it in tests

No functional change.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2018-10-26 12:56:51 +02:00
parent 9f1c81d80a
commit d8351049a8
8 changed files with 53 additions and 71 deletions
+18
View File
@@ -1221,6 +1221,24 @@ int mkostemp_safe(char *pattern) {
return fd;
}
int fmkostemp_safe(char *pattern, const char *mode, FILE **ret_f) {
int fd;
FILE *f;
fd = mkostemp_safe(pattern);
if (fd < 0)
return fd;
f = fdopen(fd, mode);
if (!f) {
safe_close(fd);
return -errno;
}
*ret_f = f;
return 0;
}
int tempfn_xxxxxx(const char *p, const char *extra, char **ret) {
const char *fn;
char *t;
+1
View File
@@ -64,6 +64,7 @@ int fflush_sync_and_check(FILE *f);
int fopen_temporary(const char *path, FILE **_f, char **_temp_path);
int mkostemp_safe(char *pattern);
int fmkostemp_safe(char *pattern, const char *mode, FILE**_f);
int tempfn_xxxxxx(const char *p, const char *extra, char **ret);
int tempfn_random(const char *p, const char *extra, char **ret);