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

Fix pointer addition with NULL pointer #373

Merged
merged 1 commit into from
May 6, 2023

Conversation

7YZ7
Copy link
Contributor

@7YZ7 7YZ7 commented Apr 23, 2023

[

为什么提交这份PR (why to submit this PR)

在第393行和第401行代码中,将 NULL 指针((char *)0)与另一个指针或整数相加。当与空指针进行算术操作时,结果是未定义的。
你的解决方案是什么 (what is your solution)
将 arg 与 (char *)0 指针相减,可以改为直接将 arg 强制转换为 int 类型。同样,将 count 与 (char *)0 相加也可以改为将 count 强制转换为 void * 类型。这里使用了 intptr_t 类型,它是一个整数类型,可以保证在转换为指针类型时不会丢失数据。

在什么测试环境下测试通过 (what is the test environment)
all

]

@tencent-adm
Copy link

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@7YZ7 7YZ7 changed the title [HUST CSE]Fix pointer addition with NULL pointer Fix pointer addition with NULL pointer Apr 23, 2023
@7YZ7 7YZ7 marked this pull request as ready for review April 23, 2023 13:48
@Supowang1989
Copy link
Collaborator

@Yangyuanxin 帮忙review下这个修改

Copy link
Collaborator

@Yangyuanxin Yangyuanxin left a comment

Choose a reason for hiding this comment

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

这份代码是Bcrypt库里的一个API自测程序,确实有你所说的这个问题。目前,应用程序逻辑正常使用的情况下不会走到这个逻辑里去。

@Supowang1989 Supowang1989 merged commit 6a82f90 into OpenAtomFoundation:master May 6, 2023
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.

4 participants