summaryrefslogtreecommitdiff
path: root/utils/hp2ps
diff options
context:
space:
mode:
authorReid Barton <rwbarton@gmail.com>2014-06-30 22:01:57 -0400
committerReid Barton <rwbarton@gmail.com>2014-06-30 22:04:00 -0400
commitb735883016b946372cb44b6c5d86dc36c126a8cf (patch)
tree27c15d282567f0e2ac5f34bfc1da552ba0c7e27c /utils/hp2ps
parentc44da48c6d19b3d8cc0ba34328576683410f8ec2 (diff)
downloadhaskell-b735883016b946372cb44b6c5d86dc36c126a8cf.tar.gz
Avoid integer overflow in hp2ps (#9145)
This is slightly hackish, but hp2ps is already convoluted enough that I don't feel bad about it.
Diffstat (limited to 'utils/hp2ps')
-rw-r--r--utils/hp2ps/HpFile.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/utils/hp2ps/HpFile.c b/utils/hp2ps/HpFile.c
index 5ee9cc259e..f2a01cd3a2 100644
--- a/utils/hp2ps/HpFile.c
+++ b/utils/hp2ps/HpFile.c
@@ -227,7 +227,7 @@ GetHpLine(FILE *infp)
Error("%s, line %d: integer must follow identifier", hpfile,
linenum);
}
- StoreSample(GetEntry(theident), nsamples, (floatish) theinteger);
+ StoreSample(GetEntry(theident), nsamples, thefloatish);
GetHpTok(infp);
break;
@@ -358,8 +358,13 @@ GetNumber(FILE *infp)
thefloatish = (floatish) atof(numberstring);
return FLOAT_TOK;
} else {
- theinteger = atoi(numberstring);
- return INTEGER_TOK;
+ theinteger = atoi(numberstring);
+ /* Set thefloatish too.
+ If this is an identifier line, the value might exceed
+ the size of 'int', and we are going to convert it to
+ a floatish anyways. */
+ thefloatish = atof(numberstring);
+ return INTEGER_TOK;
}
}