Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f9ffb03c
Commit
f9ffb03c
authored
Feb 04, 1999
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Jim Fulton: this fixes seg faults with bad pickles like "c".
parent
d673d481
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
Modules/cPickle.c
Modules/cPickle.c
+22
-3
No files found.
Modules/cPickle.c
View file @
f9ffb03c
/*
* cPickle.c,v 1.6
1 1998/11/10 00:48:51
jim Exp
* cPickle.c,v 1.6
3 1999/02/05 01:40:06
jim Exp
*
* Copyright (c) 1996-1998, Digital Creations, Fredericksburg, VA, USA.
* All rights reserved.
...
...
@@ -49,7 +49,7 @@
static
char
cPickle_module_documentation
[]
=
"C implementation and optimization of the Python pickle module
\n
"
"
\n
"
"cPickle.c,v 1.6
1 1998/11/10 00:48:51
jim Exp
\n
"
"cPickle.c,v 1.6
3 1999/02/05 01:40:06
jim Exp
\n
"
;
#include "Python.h"
...
...
@@ -2330,6 +2330,11 @@ load_none(Unpicklerobject *self) {
return
0
;
}
static
int
bad_readline
()
{
PyErr_SetString
(
UnpicklingError
,
"pickle data was truncated"
);
return
-
1
;
}
static
int
load_int
(
Unpicklerobject
*
self
)
{
...
...
@@ -2339,6 +2344,7 @@ load_int(Unpicklerobject *self) {
long
l
;
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
<
0
)
return
-
1
;
if
(
len
<
2
)
return
bad_readline
();
UNLESS
(
s
=
pystrndup
(
s
,
len
))
return
-
1
;
errno
=
0
;
...
...
@@ -2440,6 +2446,7 @@ load_long(Unpicklerobject *self) {
int
len
,
res
=
-
1
;
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
<
0
)
return
-
1
;
if
(
len
<
2
)
return
bad_readline
();
UNLESS
(
s
=
pystrndup
(
s
,
len
))
return
-
1
;
UNLESS
(
l
=
PyLong_FromString
(
s
,
&
end
,
0
))
...
...
@@ -2464,6 +2471,7 @@ load_float(Unpicklerobject *self) {
double
d
;
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
<
0
)
return
-
1
;
if
(
len
<
2
)
return
bad_readline
();
UNLESS
(
s
=
pystrndup
(
s
,
len
))
return
-
1
;
errno
=
0
;
...
...
@@ -2562,6 +2570,7 @@ load_string(Unpicklerobject *self) {
static
PyObject
*
eval_dict
=
0
;
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
<
0
)
return
-
1
;
if
(
len
<
2
)
return
bad_readline
();
UNLESS
(
s
=
pystrndup
(
s
,
len
))
return
-
1
;
/* Check for unquoted quotes (evil strings) */
...
...
@@ -2823,9 +2832,11 @@ load_inst(Unpicklerobject *self) {
if
((
i
=
marker
(
self
))
<
0
)
return
-
1
;
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
<
0
)
return
-
1
;
if
(
len
<
2
)
return
bad_readline
();
UNLESS
(
module_name
=
PyString_FromStringAndSize
(
s
,
len
-
1
))
return
-
1
;
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
>=
0
)
{
if
(
len
<
2
)
return
bad_readline
();
if
(
class_name
=
PyString_FromStringAndSize
(
s
,
len
-
1
))
{
class
=
find_class
(
module_name
,
class_name
);
Py_DECREF
(
class_name
);
...
...
@@ -2855,9 +2866,11 @@ load_global(Unpicklerobject *self) {
char
*
s
;
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
<
0
)
return
-
1
;
if
(
len
<
2
)
return
bad_readline
();
UNLESS
(
module_name
=
PyString_FromStringAndSize
(
s
,
len
-
1
))
return
-
1
;
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
>=
0
)
{
if
(
len
<
2
)
return
bad_readline
();
if
(
class_name
=
PyString_FromStringAndSize
(
s
,
len
-
1
))
{
class
=
find_class
(
module_name
,
class_name
);
Py_DECREF
(
class_name
);
...
...
@@ -2879,6 +2892,7 @@ load_persid(Unpicklerobject *self) {
if
(
self
->
pers_func
)
{
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
<
0
)
return
-
1
;
if
(
len
<
2
)
return
bad_readline
();
UNLESS
(
pid
=
PyString_FromStringAndSize
(
s
,
len
-
1
))
return
-
1
;
...
...
@@ -2994,6 +3008,7 @@ load_get(Unpicklerobject *self) {
char
*
s
;
if
((
len
=
(
*
self
->
readline_func
)(
self
,
&
s
))
<
0
)
return
-
1
;
if
(
len
<
2
)
return
bad_readline
();
UNLESS
(
py_str
=
PyString_FromStringAndSize
(
s
,
len
-
1
))
return
-
1
;
...
...
@@ -3072,6 +3087,7 @@ load_put(Unpicklerobject *self) {
char
*
s
;
if
((
l
=
(
*
self
->
readline_func
)(
self
,
&
s
))
<
0
)
return
-
1
;
if
(
len
<
2
)
return
bad_readline
();
UNLESS
(
len
=
self
->
stack
->
length
)
return
stackUnderflow
();
UNLESS
(
py_str
=
PyString_FromStringAndSize
(
s
,
l
-
1
))
return
-
1
;
value
=
self
->
stack
->
data
[
len
-
1
];
...
...
@@ -4275,10 +4291,13 @@ init_stuff(PyObject *module, PyObject *module_dict) {
return
0
;
}
#ifndef DL_EXPORT
/* declarations for DLL import/export */
#define DL_EXPORT(RTYPE) RTYPE
#endif
DL_EXPORT
(
void
)
initcPickle
()
{
PyObject
*
m
,
*
d
,
*
v
;
char
*
rev
=
"1.6
1
"
;
char
*
rev
=
"1.6
3
"
;
PyObject
*
format_version
;
PyObject
*
compatible_formats
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment