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

ngx_client模块地址拷贝错误导致踩内存 #94

Open
xbc112233 opened this issue May 18, 2022 · 8 comments
Open

ngx_client模块地址拷贝错误导致踩内存 #94

xbc112233 opened this issue May 18, 2022 · 8 comments

Comments

@xbc112233
Copy link

ngx_client_connect_server函数里面,
s->peer.sockaddr = ngx_pcalloc(s->pool, sizeof(socklen)); 这个是笔误吧?
应该是
s->peer.sockaddr = ngx_pcalloc(s->pool, socklen);
不然后面memcpy就覆盖内存了

@lystormenvoy
Copy link

ngx_pcalloc的第二个参数是size_t的吧

@xbc112233
Copy link
Author

ngx_pcalloc的第二个参数是size_t的吧

他想分配socklen长度(比如10),结果写成了sizeof(socklen)(一定是4或者8),感觉是这样,这个地方会导致出core的

@im-pingo
Copy link
Collaborator

@xbc112233 @lystormenvoy 抱歉,工作太忙没及时修复,谢谢两位指出问题

@lystormenvoy
Copy link

应该改成啥,strlen吗

@im-pingo
Copy link
Collaborator

应该改成啥,strlen吗

socklen

@lystormenvoy
Copy link

lystormenvoy commented Nov 21, 2022

应该改成啥,strlen吗

socklen

不太懂哈,直接传socklen的话,不是和参数类型对不上了吗?

btw,群主既然都有空了。不如看看这些
#93
#62 (comment)
#95

@xbc112233
Copy link
Author

  • s->peer.sockaddr = ngx_pcalloc(s->pool, sizeof(socklen));
  • s->peer.sockaddr = ngx_pcalloc(s->pool, socklen);

@xbc112233
Copy link
Author

xbc112233 commented Nov 22, 2022 via email

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

No branches or pull requests

3 participants