Skip to content

Small fixes #91

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

bibendovsky
Copy link

  • Fixed dereferencing null pointer in oggpack_writeinit
  • Fixed type cast in ogg_page_serialno and ogg_page_pageno

@@ -39,7 +39,7 @@ static const unsigned int mask8B[]=
void oggpack_writeinit(oggpack_buffer *b){
memset(b,0,sizeof(*b));
b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT);
b->buffer[0]='\0';
Copy link
Contributor

Choose a reason for hiding this comment

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

This do not look correct. If malloc() fail, I doubt b->storage should get a non-zero value as the there is no storage available.

Copy link
Author

Choose a reason for hiding this comment

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

This do not look correct. If malloc() fail, I doubt b->storage should get a non-zero value as the there is no storage available.

The fix do the check for a null. You can see this under the review conversation.

Copy link
Contributor

Choose a reason for hiding this comment

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

I do not understand your comment. I see the addition of if(b->buffer) in your patch, but fail to see how this properly handle the case where malloc() return NULL, as it seem incomplete and returning a misleading state from the oggpack_writeinit() method. Why is your edition still modifying b->storage if there is no memory area pointed to by b->buffer?

Copy link
Contributor

Choose a reason for hiding this comment

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

I created https://gitlab.xiph.org/xiph/ogg/-/merge_requests/26 with my proposed fix for the same issue, including updating the documentation to mention that the method can fail.

Copy link
Author

Choose a reason for hiding this comment

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

I do not understand your comment. I see the addition of if(b->buffer) in your patch, but fail to see how this properly handle the case where malloc() return NULL

Conditional operator if (b->buffer) prevents from writing '\0' into b->buffer when it is null.

but fail to see how this properly handle the case where malloc() return NULL, as it seem incomplete and returning a misleading state from the oggpack_writeinit() method.

The commit do exactly what it says - nothing more, nothing less.
I could add another commit to address this exact issue (the incomplete state).

Why is your edition still modifying b->storage if there is no memory area pointed to by b->buffer?

That was in original code.

@petterreinholdtsen
Copy link
Contributor

petterreinholdtsen commented Mar 21, 2025 via email

jollaitbot pushed a commit to sailfishos-mirror/ogg that referenced this pull request Mar 21, 2025
jollaitbot pushed a commit to sailfishos-mirror/ogg that referenced this pull request Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants