Skip to content

Fixes https://github.com/curl/curl/issues/6696 - #6697

Closed
kokke wants to merge 2 commits into
curl:masterfrom
kokke:patch-1
Closed

Fixes https://github.com/curl/curl/issues/6696#6697
kokke wants to merge 2 commits into
curl:masterfrom
kokke:patch-1

Conversation

@kokke

@kokke kokke commented Mar 5, 2021

Copy link
Copy Markdown
Contributor

Fixes #6696

From lib/c-hyper.c:445-467 - n is checked against NULL instead of p, at line 467
I have inserted comments at line 445 and 467.

445    p = strchr(n, ':'); /* <-- n assumed non-NULL here, since dereferenced */
446    if(!p)
447      /* this is fine if we already added at least one header */
448      return numh ? CURLE_OK : CURLE_BAD_FUNCTION_ARGUMENT;
449    nlen = p - n;
450    p++; /* move past the colon */
451    while(*p == ' ')
452      p++;
453    v = p;
454    p = strchr(v, '\r');
455    if(!p) {
456      p = strchr(v, '\n');
457      if(p)
458        linelen = 1; /* LF only */
459      else {
460        p = strchr(v, '\0');
461        newline = FALSE; /* no newline */
462      }
463    }
464    else
465      linelen = 2; /* CRLF ending */
466    linelen += (p - n);
467    if(!n) /* <-- n was assumed non-NULL above, should this have been 'if(!p)' ? */
468      return CURLE_BAD_FUNCTION_ARGUMENT;
469    vlen = p - v; 

Comment thread lib/c-hyper.c Outdated
linelen = 2; /* CRLF ending */
linelen += (p - n);
if(!n)
if(!p)

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.

AFAICS neither n nor p can be null here so I don't know why that check is there. Do you want to adjust your PR to remove it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You mean remove the entire if-statement?

467    if(!p)
468      return CURLE_BAD_FUNCTION_ARGUMENT;

@jay jay added the Hyper label Mar 5, 2021
@ghost

ghost commented Mar 5, 2021

Copy link
Copy Markdown

Congratulations 🎉. DeepCode analyzed your code in 2.995 seconds and we found no issues. Enjoy a moment of no bugs ☀️.

👉 View analysis in DeepCode’s Dashboard | Configure the bot

@jay jay added the tidy-up label Mar 5, 2021
@jay jay closed this in 86338ca Mar 5, 2021
@jay

jay commented Mar 5, 2021

Copy link
Copy Markdown
Member

Thanks

@kokke

kokke commented Mar 5, 2021

Copy link
Copy Markdown
Contributor Author

Thank you for super-swift action @jay 👍 have a great weekend :)

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.

possibly null-check against wrong variable

2 participants