[commit: ghc] master: Avoid integer overflow in hp2ps (#9145) (b735883)

git at git.haskell.org git at git.haskell.org
Tue Jul 1 02:06:46 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/b735883016b946372cb44b6c5d86dc36c126a8cf/ghc

>---------------------------------------------------------------

commit b735883016b946372cb44b6c5d86dc36c126a8cf
Author: Reid Barton <rwbarton at gmail.com>
Date:   Mon Jun 30 22:01:57 2014 -0400

    Avoid integer overflow in hp2ps (#9145)
    
    This is slightly hackish, but hp2ps is already convoluted enough
    that I don't feel bad about it.


>---------------------------------------------------------------

b735883016b946372cb44b6c5d86dc36c126a8cf
 utils/hp2ps/HpFile.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/utils/hp2ps/HpFile.c b/utils/hp2ps/HpFile.c
index 5ee9cc2..f2a01cd 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;
     }
 }
 



More information about the ghc-commits mailing list