diff options
author | Chris Liddell <chris.liddell@artifex.com> | 2021-01-28 09:31:29 +0000 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2021-01-28 09:31:29 +0000 |
commit | a448691e97cc4b4b7040e8c7d7a39e13eedfc0c2 (patch) | |
tree | f2d5cde5a2f7458ed54f1a5be1fb034c3d4f4056 /psi/iutil.c | |
parent | 66a8ec27ede82a353cb2775c4be1904aca529b2a (diff) | |
download | ghostpdl-a448691e97cc4b4b7040e8c7d7a39e13eedfc0c2.tar.gz |
oss-fuzz 27399: Handle NaN and Inf in object type conversions
In the core of cvs detect unrepresentable floating point numbers and throw
an error (note: not using fpclassify or similar because they are C99 additions).
If we hit such a case, throw an error, in this case undefinedresult - we
cannot use rangecheck because that gets special handling which also triggers
the uninitialized value error.
Diffstat (limited to 'psi/iutil.c')
-rw-r--r-- | psi/iutil.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/psi/iutil.c b/psi/iutil.c index f2d960cd4..e15cef9bf 100644 --- a/psi/iutil.c +++ b/psi/iutil.c @@ -339,9 +339,12 @@ obj_cvp(const ref * op, byte * str, uint len, uint * prlen, */ float value = op->value.realval; float scanned; - - gs_sprintf(buf, "%g", value); - (void)sscanf(buf, "%f", &scanned); + code = gs_sprintf(buf, "%g", value); + if (code <= 0) + return_error(gs_error_undefinedresult); + code = sscanf(buf, "%f", &scanned); + if (code <= 0) + return_error(gs_error_undefinedresult); if (scanned != value) gs_sprintf(buf, "%.9g", value); ensure_dot(buf); |