Skip to content

Commit ba5a3f2

Browse files
committed
backport 2.35:
SF bug 485175: buffer overflow in traceback.c. Bugfix candidate. tb_displayline(): the sprintf format was choking off the file name, but used plain %s for the function name (which can be arbitrarily long). Limit both to 500 chars max.
1 parent 8d0b5ad commit ba5a3f2

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎Python/traceback.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,16 @@ tb_displayline(PyObject *f, char *filename, int lineno, char *name)
103103
{
104104
int err = 0;
105105
FILE *xfp;
106-
char linebuf[1000];
106+
char linebuf[2000];
107107
int i;
108108
if (filename == NULL || name == NULL)
109109
return -1;
110110
#ifdef MPW
111111
/* This is needed by MPW's File and Line commands */
112-
#define FMT " File \"%.900s\"; line %d # in %s\n"
112+
#define FMT " File \"%.500s\"; line %d # in %.500s\n"
113113
#else
114114
/* This is needed by Emacs' compile command */
115-
#define FMT " File \"%.900s\", line %d, in %s\n"
115+
#define FMT " File \"%.500s\", line %d, in %.500s\n"
116116
#endif
117117
xfp = fopen(filename, "r");
118118
if (xfp == NULL) {

0 commit comments

Comments
 (0)