Skip to content

gh-113343: Fix error check on mmap(2)#113342

Merged
pablogsal merged 1 commit into
python:mainfrom
namhyung:mmap-fix
Dec 21, 2023
Merged

gh-113343: Fix error check on mmap(2)#113342
pablogsal merged 1 commit into
python:mainfrom
namhyung:mmap-fix

Conversation

@namhyung

@namhyung namhyung commented Dec 20, 2023

Copy link
Copy Markdown
Contributor

According to the man page, mmap(2) returns MAP_FAILED (-1) on error instead of NULL.

It should check MAP_FAILED instead of NULL for error.

On mmap(2) man page:

  RETURN VALUE
       On success, mmap() returns a pointer to the mapped area.
       On error, the value MAP_FAILED (that is, (void *) -1) is
       returned, and errno is set to indicate the error.
@ghost

ghost commented Dec 20, 2023

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app

bedevere-app Bot commented Dec 20, 2023

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@corona10

corona10 commented Dec 21, 2023

Copy link
Copy Markdown
Member

According to the man page, mmap(2) returns MAP_FAILED (-1) on error instead of NULL.

Would you like to create an issue for this too?

@corona10 corona10 changed the title Fix error check on mmap(2) gh-113343: Fix error check on mmap(2) Dec 21, 2023
@corona10

corona10 commented Dec 21, 2023

Copy link
Copy Markdown
Member

@pablogsal I created the issue for this PR and linked it, so you can merge this PR anytime.

@namhyung

Copy link
Copy Markdown
Contributor Author

@corona10 Thanks for doing that. I'm not familiar with the python dev process so I didn't know it's needed to create an issue first for this kind of mior problems.

@corona10

Copy link
Copy Markdown
Member

so I didn't know it's needed to create an issue first for this kind of mior problems.

For typos, we usually skip but for the technical things, I prefer to create it to track the history.

@pablogsal pablogsal merged commit 6b70c3d into python:main Dec 21, 2023
@miss-islington-app

Copy link
Copy Markdown

Thanks @namhyung for the PR, and @pablogsal for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Dec 21, 2023

Copy link
Copy Markdown

GH-113374 is a backport of this pull request to the 3.12 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 21, 2023
Fix error check on mmap(2)

It should check MAP_FAILED instead of NULL for error.

On mmap(2) man page:

  RETURN VALUE
       On success, mmap() returns a pointer to the mapped area.
       On error, the value MAP_FAILED (that is, (void *) -1) is
       returned, and errno is set to indicate the error.
(cherry picked from commit 6b70c3d)

Co-authored-by: Namhyung Kim <namhyung@gmail.com>
@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Dec 21, 2023
@pablogsal

pablogsal commented Dec 21, 2023

Copy link
Copy Markdown
Member

Thanks for the PR @namhyung and congrats on your first PR in CPython :)

@namhyung

Copy link
Copy Markdown
Contributor Author

@pablogsal and @corona10 thanks for your help!

pablogsal pushed a commit that referenced this pull request Dec 21, 2023
gh-113343: Fix error check on mmap(2) (GH-113342)

Fix error check on mmap(2)

It should check MAP_FAILED instead of NULL for error.

On mmap(2) man page:

  RETURN VALUE
       On success, mmap() returns a pointer to the mapped area.
       On error, the value MAP_FAILED (that is, (void *) -1) is
       returned, and errno is set to indicate the error.
(cherry picked from commit 6b70c3d)

Co-authored-by: Namhyung Kim <namhyung@gmail.com>
ryan-duve pushed a commit to ryan-duve/cpython that referenced this pull request Dec 26, 2023
Fix error check on mmap(2)

It should check MAP_FAILED instead of NULL for error.

On mmap(2) man page:

  RETURN VALUE
       On success, mmap() returns a pointer to the mapped area.
       On error, the value MAP_FAILED (that is, (void *) -1) is
       returned, and errno is set to indicate the error.
kulikjak pushed a commit to kulikjak/cpython that referenced this pull request Jan 22, 2024
Fix error check on mmap(2)

It should check MAP_FAILED instead of NULL for error.

On mmap(2) man page:

  RETURN VALUE
       On success, mmap() returns a pointer to the mapped area.
       On error, the value MAP_FAILED (that is, (void *) -1) is
       returned, and errno is set to indicate the error.
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Fix error check on mmap(2)

It should check MAP_FAILED instead of NULL for error.

On mmap(2) man page:

  RETURN VALUE
       On success, mmap() returns a pointer to the mapped area.
       On error, the value MAP_FAILED (that is, (void *) -1) is
       returned, and errno is set to indicate the error.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Fix error check on mmap(2)

It should check MAP_FAILED instead of NULL for error.

On mmap(2) man page:

  RETURN VALUE
       On success, mmap() returns a pointer to the mapped area.
       On error, the value MAP_FAILED (that is, (void *) -1) is
       returned, and errno is set to indicate the error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants