Skip to content

Commit 065902c

Browse files
committed
Fix Coverity defect #1457195
1 parent d9ecc48 commit 065902c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/utils.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ make_ancestors(char *path, mode_t perm)
429429
}
430430

431431
int
432-
file_create(struct error *err, const char *path, void *data, uid_t uid, gid_t gid, mode_t mode)
432+
file_create(struct error *err, const char *path, const char *data, uid_t uid, gid_t gid, mode_t mode)
433433
{
434434
char *p;
435435
uid_t euid;
@@ -461,6 +461,10 @@ file_create(struct error *err, const char *path, void *data, uid_t uid, gid_t gi
461461
if (mkdir(path, perm) < 0 && errno != EEXIST)
462462
goto fail;
463463
} else if (S_ISLNK(mode)) {
464+
if (data == NULL) {
465+
errno = EINVAL;
466+
goto fail;
467+
}
464468
if (symlink(data, path) < 0 && errno != EEXIST)
465469
goto fail;
466470
} else {

src/utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const char **array_append(const char **, const char * const [], size_t);
6161

6262
void *file_map(struct error *, const char *, size_t *);
6363
int file_unmap(struct error *, const char *, void *, size_t);
64-
int file_create(struct error *, const char *, void *, uid_t, gid_t, mode_t);
64+
int file_create(struct error *, const char *, const char *, uid_t, gid_t, mode_t);
6565
int file_remove(struct error *, const char *);
6666
int file_exists(struct error *, const char *);
6767
int file_mode(struct error *, const char *, mode_t *);

0 commit comments

Comments
 (0)