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
c9d668c0
Commit
c9d668c0
authored
7 years ago
by
Christian Heimes
Committed by
GitHub
7 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.7] bpo-30502: Fix handling of long oids in ssl. (GH-2909). (#3322)
(cherry picked from commit
e503ca52
)
parent
aa23144d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
41 deletions
+49
-41
Misc/NEWS.d/next/Library/2017-07-27-11-33-58.bpo-30502.GJlfU8.rst
...S.d/next/Library/2017-07-27-11-33-58.bpo-30502.GJlfU8.rst
+1
-0
Modules/_ssl.c
Modules/_ssl.c
+48
-41
No files found.
Misc/NEWS.d/next/Library/2017-07-27-11-33-58.bpo-30502.GJlfU8.rst
0 → 100644
View file @
c9d668c0
Fix handling of long oids in ssl. Based on patch by Christian Heimes.
This diff is collapsed.
Click to expand it.
Modules/_ssl.c
View file @
c9d668c0
...
@@ -676,49 +676,67 @@ error:
...
@@ -676,49 +676,67 @@ error:
}
}
static
PyObject
*
static
PyObject
*
_create_tuple_for_attribute
(
ASN1_OBJECT
*
name
,
ASN1_STRING
*
value
)
{
_asn1obj2py
(
const
ASN1_OBJECT
*
name
,
int
no_name
)
{
char
namebuf
[
X509_NAME_MAXLEN
];
char
buf
[
X509_NAME_MAXLEN
];
char
*
namebuf
=
buf
;
int
buflen
;
int
buflen
;
PyObject
*
name_obj
;
PyObject
*
name_obj
=
NULL
;
PyObject
*
value_obj
;
PyObject
*
attr
;
unsigned
char
*
valuebuf
=
NULL
;
buflen
=
OBJ_obj2txt
(
namebuf
,
sizeof
(
namebuf
),
name
,
0
);
buflen
=
OBJ_obj2txt
(
namebuf
,
X509_NAME_MAXLEN
,
name
,
no_name
);
if
(
buflen
<
0
)
{
if
(
buflen
<
0
)
{
_setSSLError
(
NULL
,
0
,
__FILE__
,
__LINE__
);
_setSSLError
(
NULL
,
0
,
__FILE__
,
__LINE__
);
goto
fail
;
return
NULL
;
}
/* initial buffer is too small for oid + terminating null byte */
if
(
buflen
>
X509_NAME_MAXLEN
-
1
)
{
/* make OBJ_obj2txt() calculate the required buflen */
buflen
=
OBJ_obj2txt
(
NULL
,
0
,
name
,
no_name
);
/* allocate len + 1 for terminating NULL byte */
namebuf
=
PyMem_Malloc
(
buflen
+
1
);
if
(
namebuf
==
NULL
)
{
PyErr_NoMemory
();
return
NULL
;
}
buflen
=
OBJ_obj2txt
(
namebuf
,
buflen
+
1
,
name
,
no_name
);
if
(
buflen
<
0
)
{
_setSSLError
(
NULL
,
0
,
__FILE__
,
__LINE__
);
goto
done
;
}
}
if
(
!
buflen
&&
no_name
)
{
Py_INCREF
(
Py_None
);
name_obj
=
Py_None
;
}
else
{
name_obj
=
PyString_FromStringAndSize
(
namebuf
,
buflen
);
}
}
name_obj
=
PyString_FromStringAndSize
(
namebuf
,
buflen
);
if
(
name_obj
==
NULL
)
done:
goto
fail
;
if
(
buf
!=
namebuf
)
{
PyMem_Free
(
namebuf
);
}
return
name_obj
;
}
static
PyObject
*
_create_tuple_for_attribute
(
ASN1_OBJECT
*
name
,
ASN1_STRING
*
value
)
{
Py_ssize_t
buflen
;
unsigned
char
*
valuebuf
=
NULL
;
PyObject
*
attr
,
*
value_obj
;
buflen
=
ASN1_STRING_to_UTF8
(
&
valuebuf
,
value
);
buflen
=
ASN1_STRING_to_UTF8
(
&
valuebuf
,
value
);
if
(
buflen
<
0
)
{
if
(
buflen
<
0
)
{
_setSSLError
(
NULL
,
0
,
__FILE__
,
__LINE__
);
_setSSLError
(
NULL
,
0
,
__FILE__
,
__LINE__
);
Py_DECREF
(
name_obj
);
return
NULL
;
goto
fail
;
}
}
value_obj
=
PyUnicode_DecodeUTF8
((
char
*
)
valuebuf
,
value_obj
=
PyUnicode_DecodeUTF8
((
char
*
)
valuebuf
,
buflen
,
"strict"
);
buflen
,
"strict"
);
attr
=
Py_BuildValue
(
"NN"
,
_asn1obj2py
(
name
,
0
),
value_obj
);
OPENSSL_free
(
valuebuf
);
OPENSSL_free
(
valuebuf
);
if
(
value_obj
==
NULL
)
{
Py_DECREF
(
name_obj
);
goto
fail
;
}
attr
=
PyTuple_New
(
2
);
if
(
attr
==
NULL
)
{
Py_DECREF
(
name_obj
);
Py_DECREF
(
value_obj
);
goto
fail
;
}
PyTuple_SET_ITEM
(
attr
,
0
,
name_obj
);
PyTuple_SET_ITEM
(
attr
,
1
,
value_obj
);
return
attr
;
return
attr
;
fail:
return
NULL
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -3576,8 +3594,6 @@ asn1obj2py(ASN1_OBJECT *obj)
...
@@ -3576,8 +3594,6 @@ asn1obj2py(ASN1_OBJECT *obj)
{
{
int
nid
;
int
nid
;
const
char
*
ln
,
*
sn
;
const
char
*
ln
,
*
sn
;
char
buf
[
100
];
Py_ssize_t
buflen
;
nid
=
OBJ_obj2nid
(
obj
);
nid
=
OBJ_obj2nid
(
obj
);
if
(
nid
==
NID_undef
)
{
if
(
nid
==
NID_undef
)
{
...
@@ -3586,16 +3602,7 @@ asn1obj2py(ASN1_OBJECT *obj)
...
@@ -3586,16 +3602,7 @@ asn1obj2py(ASN1_OBJECT *obj)
}
}
sn
=
OBJ_nid2sn
(
nid
);
sn
=
OBJ_nid2sn
(
nid
);
ln
=
OBJ_nid2ln
(
nid
);
ln
=
OBJ_nid2ln
(
nid
);
buflen
=
OBJ_obj2txt
(
buf
,
sizeof
(
buf
),
obj
,
1
);
return
Py_BuildValue
(
"issN"
,
nid
,
sn
,
ln
,
_asn1obj2py
(
obj
,
1
));
if
(
buflen
<
0
)
{
_setSSLError
(
NULL
,
0
,
__FILE__
,
__LINE__
);
return
NULL
;
}
if
(
buflen
)
{
return
Py_BuildValue
(
"isss#"
,
nid
,
sn
,
ln
,
buf
,
buflen
);
}
else
{
return
Py_BuildValue
(
"issO"
,
nid
,
sn
,
ln
,
Py_None
);
}
}
}
PyDoc_STRVAR
(
PySSL_txt2obj_doc
,
PyDoc_STRVAR
(
PySSL_txt2obj_doc
,
...
...
This diff is collapsed.
Click to expand it.
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