Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null Pointer Dereference in lib #18071

Open
2 tasks done
mugitya03 opened this issue Feb 9, 2025 · 2 comments
Open
2 tasks done

Null Pointer Dereference in lib #18071

mugitya03 opened this issue Feb 9, 2025 · 2 comments
Labels
triage Needs further investigation

Comments

@mugitya03
Copy link

Description

Dear Developers,

We found function ls_vertex_add can return NULL value when key is invalid or XCALLOC fails.

	/* Check that key is valid */
	if (key == 0)
		return NULL;

	/* Create Vertex and add it to the TED */
	new = XCALLOC(MTYPE_LS_DB, sizeof(struct ls_vertex));
	if (!new)
		return NULL;

However, some caller functions don't check the return value of ls_vertex_add before dereferencing, causing potential null pointer dereference bugs.

  • vertex = ls_vertex_add(ted, node); link
  • vertex = ls_vertex_add(ted, node); link
  • vertex = ls_vertex_add(ted, old); link
  • vertex = ls_vertex_add(ted, lnode); link

We found that some call functions already perform a null value check on the return value before dereferencing (link, link). Therefore, we believe the above call sites also need to add such checks.

Version

latest master

How to reproduce

When key is invalid or XCALLOC fails, the function ls_vertex_add can return NULL value.

Expected behavior

No

Actual behavior

No

Additional context

No response

Checklist

  • I have searched the open issues for this bug.
  • I have not included sensitive information in this report.
@mugitya03 mugitya03 added the triage Needs further investigation label Feb 9, 2025
@mugitya03
Copy link
Author

@ton31337 Could you please take a look at these issues? They appear to be similar to 18072 due to missing null value checks, but I'm unsure of the best way to fix them.

@donaldsharp
Copy link
Member

remove the key == 0 and change it to a assert so it doesn't return null. Remove the if (!new) null check it's bogus. Problem solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Needs further investigation
Projects
None yet
Development

No branches or pull requests

2 participants