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

Removed a bug which could cause a crash in HeaderParser, and as consequence could potentially crash a web server based on it #22

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Next
removed bug caused by uninitialized variable h in function HeaderPars…
…er.prototype._parseHeader
  • Loading branch information
RolandHeinze committed Aug 10, 2021
commit b7fca2e93e8e9d4439d8acc5c02f5e54a0112dac
38 changes: 20 additions & 18 deletions lib/HeaderParser.js
Expand Up @@ -82,26 +82,28 @@ HeaderParser.prototype._parseHeader = function() {
// folded header content
// RFC2822 says to just remove the CRLF and not the whitespace following
// it, so we follow the RFC and include the leading whitespace ...
this.header[h][this.header[h].length - 1] += lines[i];
} else {
m = RE_HDR.exec(lines[i]);
if (m) {
h = m[1].toLowerCase();
if (m[2]) {
if (this.header[h] === undefined)
this.header[h] = [m[2]];
else
this.header[h].push(m[2]);
} else
this.header[h] = [''];
if (++this.npairs === this.maxHeaderPairs)
break;
} else {
this.buffer = lines[i];
modded = true;
break;
if (h) {
this.header[h][this.header[h].length - 1] += lines[i];
continue;
}
}
m = RE_HDR.exec(lines[i]);
if (m) {
h = m[1].toLowerCase();
if (m[2]) {
if (this.header[h] === undefined)
this.header[h] = [m[2]];
else
this.header[h].push(m[2]);
} else
this.header[h] = [''];
if (++this.npairs === this.maxHeaderPairs)
break;
} else {
this.buffer = lines[i];
modded = true;
break;
}
}
if (!modded)
this.buffer = '';
Expand Down