Skip to content

Conversation

@Sapna1-singh
Copy link

Below are the issues fixed:

  • Buffer not null terminated
  • Resource leak

Tracked-On: OAM-122340

libsync.h Outdated
int ret;

data.fd2 = fd2;
strncpy(data.name, name, sizeof(data.name));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the copy be guarded against the length of name like this:

	if (sizeof(data.name) < strlen(name)) {
            strncpy(data.name, name, sizeof(data.name));
            data.name[sizeof(data.name) - 1] = '\0';
	} else {
            strncpy(data.name, name, strlen(name) - 1);
            data.name[strlen(name)] = '\0';
    }

Copy link

@akodanka akodanka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

assert(pgsz > 0);

if (pgsz < 0)
return false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add indentation space before return false

}
return "";
// Adding an assertion to indicate that this point should never be reached.
__builtin_unreachable();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check for indentation

xf86drm.c Outdated
chown_check_return(buf, user, group);
chmod(buf, devmode);
if (chmod(buf, devmode) != 0)
return errno;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add space before return errno

xf86drm.c Outdated
chown_check_return(buf, user, group);
chmod(buf, devmode);
if (chmod(buf, devmode) != 0)
return errno;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add space before return errno

if (!gen)
return NULL;
// LOGICALLY_DEAD_CODE: As the value of gen can't be 0.
//if (!gen)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove these lines

Below are the issues fixed:
- Buffer not null terminated
- Resource leak
- Logically dead code
- Argument cannot be negative
- Dead default in switch
- Dereference after null check
- Unchecked return value
- Data race condition
- Unchecked return value from library

Tracked-On: OAM-122340
Signed-off-by: Sapna <[email protected]>
@feijiang1
Copy link

These coverity issues are related upstream code, then we can directly get waiver for them, don't need fix actually. If we need fix them, it is better directly submit to upstream repo.

@sysopenci sysopenci added the Stale Stale label for inactive open prs label Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stale Stale label for inactive open prs Valid commit message

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants