Skip to content

Potential null pointer dereference #188

@qingkaishi

Description

@qingkaishi

Hi

I found a potential null pointer dereference. Although it looks improbabl, it is possible.

https://github.com/vmware/open-vm-tools/blob/master/open-vm-tools/lib/misc/timeutil.c#L855


#if defined sun
str = Util_SafeStrdup(ctime_r(&t, buf, sizeof buf));
#else
str = Util_SafeStrdup(ctime_r(&t, buf)); // step 1: null may be returned if ctime_r fails
#endif
str[strlen(str) - 1] = '\0'; // Remove the trailing '\n'.

return str; // step 2: return the null pointer and dereference it.


According to the linux document, ctime_r may return null if an internal error happens, which makes the null pointer dereference possible.

Although it looks improbable, I suggest to patch it for better stability.

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