X-Git-Url: https://gitweb.michael.orlitzky.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Flibadacl.c;h=5402a32be0ac3ca03a535aa40bf049ef1eabca3f;hb=71831f01c40806756b6640591fca739c7790aebe;hp=a1923601669b66efb0ffa45e62a9b73695354ddb;hpb=0b4ff086871b13edb9da3bda67ac4b6f710e73dd;p=apply-default-acl.git diff --git a/src/libadacl.c b/src/libadacl.c index a192360..5402a32 100644 --- a/src/libadacl.c +++ b/src/libadacl.c @@ -56,8 +56,12 @@ * and @c OPEN_ERROR if not. */ int safe_open_ex(int at_fd, char* pathname, int flags) { - /* We're only called by safe_open(), so pathname is guaranteed to be - non-NULL */ + if (pathname == NULL) { + errno = EINVAL; + perror("safe_open_ex (args)"); + return OPEN_ERROR; + } + if (strlen(pathname) == 0) { /* Oops, went one level to deep with nothing to do. */ return at_fd; @@ -210,6 +214,11 @@ int safe_open(const char* pathname, int flags) { * */ int acl_set_entry(acl_t* aclp, acl_entry_t entry) { + if (aclp == NULL || entry == NULL) { + errno = EINVAL; + perror("acl_set_entry (args)"); + return ACL_ERROR; + } acl_tag_t entry_tag; if (acl_get_tag_type(entry, &entry_tag) == ACL_ERROR) { @@ -358,6 +367,11 @@ int acl_entry_count(acl_t acl) { * - @c ACL_ERROR - Unexpected library error */ int acl_is_minimal(acl_t acl) { + if (acl == NULL) { + errno = EINVAL; + perror("acl_is_minimal (args)"); + return ACL_ERROR; + } int ec = acl_entry_count(acl); @@ -388,6 +402,11 @@ int acl_is_minimal(acl_t acl) { * - @c ACL_ERROR - Unexpected library error. */ int acl_execute_masked(acl_t acl) { + if (acl == NULL) { + errno = EINVAL; + perror("acl_execute_masked (args)"); + return ACL_ERROR; + } acl_entry_t entry; int ge_result = acl_get_entry(acl, ACL_FIRST_ENTRY, &entry); @@ -451,6 +470,12 @@ int acl_execute_masked(acl_t acl) { * - @c ACL_ERROR - Unexpected library error. */ int any_can_execute(int fd, const struct stat* sp) { + if (sp == NULL) { + errno = EINVAL; + perror("any_can_execute (args)"); + return ACL_ERROR; + } + acl_t acl = acl_get_fd(fd); if (acl == (acl_t)NULL) { @@ -548,8 +573,7 @@ int any_can_execute(int fd, const struct stat* sp) { * - @c ACL_ERROR - Unexpected library error. */ int assign_default_acl(const char* path, acl_t acl) { - - if (path == NULL) { + if (path == NULL || acl == NULL) { errno = EINVAL; perror("assign_default_acl (args)"); return ACL_ERROR;