Skip to content

Update socks.c#5654

Closed
ihsinme wants to merge 1 commit into
curl:masterfrom
ihsinme:patch-1
Closed

Update socks.c#5654
ihsinme wants to merge 1 commit into
curl:masterfrom
ihsinme:patch-1

Conversation

@ihsinme
Copy link
Copy Markdown
Contributor

@ihsinme ihsinme commented Jul 5, 2020

I propose to eliminate the risk of using the signed type (ssize_t) in the arithmetic of pointers, replacing it with an unsigned one (size_t). While in this context, the signed type (ssize_t) is used unnecessarily.

I propose to eliminate the risk of using the signed type (ssize_t) in the arithmetic of pointers, replacing it with an unsigned one (size_t). While in this context, the signed type (ssize_t) is used unnecessarily.
Copy link
Copy Markdown
Member

@danielgustafsson danielgustafsson left a comment

Choose a reason for hiding this comment

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

The outstanding member in struct connstate is of type ssize_t, so it makes sense to calculate using that type. Also, I'm not sure I see the the threat vector here, can you elaborate on why you think ssize_t is dangerous here?

Comment thread lib/socks.c
*/
{
ssize_t packetsize = 9 +
size_t packetsize = 9 +
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is bogus indentation.

@ihsinme
Copy link
Copy Markdown
Contributor Author

ihsinme commented Jul 6, 2020

I see a threat in the following.
when the variables packetsize, hostnamelen or their sum increase beyond positive values, memory overflow to which socksreq packetsize points can occur. however, ongoing checks will not provide protection.

@bagder
Copy link
Copy Markdown
Member

bagder commented Jul 7, 2020

I don't think that's a "threat", but since the fix removes a typecast I still think its a good one.

@bagder bagder closed this in 60aa961 Jul 12, 2020
@bagder
Copy link
Copy Markdown
Member

bagder commented Jul 12, 2020

Thanks!

@ihsinme
Copy link
Copy Markdown
Contributor Author

ihsinme commented Jul 12, 2020

Thanks you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants