Skip to content

Null pointer dereference in eigerDetector::writeOctet if name for user's GID is missing #85

@nmarks99

Description

@nmarks99

In the presumably rare situation where a user's owning group is not found, e.g.:

$ id -gn
id: cannot find name for group ID 3468
3468

eigerDetector::writeOctet causes a segmentation fault due to dereferencing a null pointer which is returned from getgrgid() if the group isn't found. The segfault occurs shortly after IOC init and there is no helpful error message to diagnose the problem.

mFileOwnerGroup->put(getgrgid(mFsGid)->gr_name);

I tested this situation with a minimal example program and compared the results for an account with a valid group and another with an invalid group ID:

// file: check_gid.cpp
#include <iostream>
#include <unistd.h>
#include <grp.h>
int main() {
    struct group* p_group = getgrgid(getgid());
    std::cout << p_group->gr_name << std::endl;
# Account with valid gid
$ id -gn
aesbc
$ ./check_gid
aesbc

# Account with invalid gid
$ id -gn
id: cannot find name for group ID 3468
3468
$ ./check_gid
Segmentation fault (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions