Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4feda2a

Browse files
committed
Merged revisions 70682,70684 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r70682 | mark.dickinson | 2009-03-29 17:17:16 +0100 (Sun, 29 Mar 2009) | 3 lines Issue #532631: Add paranoid check to avoid potential buffer overflow on systems with sizeof(int) > 4. ........ r70684 | mark.dickinson | 2009-03-29 17:24:29 +0100 (Sun, 29 Mar 2009) | 3 lines Issue #532631: Apply floatformat changes to unicodeobject.c as well as stringobject.c. ........
1 parent c8a608c commit 4feda2a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Objects/unicodeobject.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8847,6 +8847,15 @@ formatfloat(Py_UNICODE *buf,
88478847
return -1;
88488848
if (prec < 0)
88498849
prec = 6;
8850+
/* make sure that the decimal representation of precision really does
8851+
need at most 10 digits: platforms with sizeof(int) == 8 exist! */
8852+
if (prec > 0x7fffffffL) {
8853+
PyErr_SetString(PyExc_OverflowError,
8854+
"outrageously large precision "
8855+
"for formatted float");
8856+
return -1;
8857+
}
8858+
88508859
if (type == 'f' && fabs(x) >= 1e50)
88518860
type = 'g';
88528861
/* Worst case length calc to ensure no buffer overrun:

0 commit comments

Comments
 (0)