Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c5a216e0
Unverified
Kaydet (Commit)
c5a216e0
authored
Mar 20, 2019
tarafından
Inada Naoki
Kaydeden (comit)
GitHub
Mar 20, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-8677: use PY_SSIZE_T_CLEAN in Modules/_gdbmodule.c (GH-12464)
üst
9b4a1b1e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
9 deletions
+27
-9
_gdbmmodule.c
Modules/_gdbmmodule.c
+27
-9
No files found.
Modules/_gdbmmodule.c
Dosyayı görüntüle @
c5a216e0
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
/* Author: Anthony Baxter, after dbmmodule.c */
/* Author: Anthony Baxter, after dbmmodule.c */
/* Doc strings: Mitch Chapman */
/* Doc strings: Mitch Chapman */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "Python.h"
#include <sys/types.h>
#include <sys/types.h>
...
@@ -119,15 +119,36 @@ dbm_length(dbmobject *dp)
...
@@ -119,15 +119,36 @@ dbm_length(dbmobject *dp)
return
dp
->
di_size
;
return
dp
->
di_size
;
}
}
// Wrapper function for PyArg_Parse(o, "s#", &d.dptr, &d.size).
// This function is needed to support PY_SSIZE_T_CLEAN.
// Return 1 on success, same to PyArg_Parse().
static
int
parse_datum
(
PyObject
*
o
,
datum
*
d
,
const
char
*
failmsg
)
{
Py_ssize_t
size
;
if
(
!
PyArg_Parse
(
o
,
"s#"
,
&
d
->
dptr
,
&
size
))
{
if
(
failmsg
!=
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
failmsg
);
}
return
0
;
}
if
(
INT_MAX
<
size
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"size does not fit in an int"
);
return
0
;
}
d
->
dsize
=
size
;
return
1
;
}
static
PyObject
*
static
PyObject
*
dbm_subscript
(
dbmobject
*
dp
,
PyObject
*
key
)
dbm_subscript
(
dbmobject
*
dp
,
PyObject
*
key
)
{
{
PyObject
*
v
;
PyObject
*
v
;
datum
drec
,
krec
;
datum
drec
,
krec
;
if
(
!
PyArg_Parse
(
key
,
"s#"
,
&
krec
.
dptr
,
&
krec
.
dsize
)
)
if
(
!
parse_datum
(
key
,
&
krec
,
NULL
))
{
return
NULL
;
return
NULL
;
}
if
(
dp
->
di_dbm
==
NULL
)
{
if
(
dp
->
di_dbm
==
NULL
)
{
PyErr_SetString
(
DbmError
,
PyErr_SetString
(
DbmError
,
"GDBM object has already been closed"
);
"GDBM object has already been closed"
);
...
@@ -172,10 +193,9 @@ static int
...
@@ -172,10 +193,9 @@ static int
dbm_ass_sub
(
dbmobject
*
dp
,
PyObject
*
v
,
PyObject
*
w
)
dbm_ass_sub
(
dbmobject
*
dp
,
PyObject
*
v
,
PyObject
*
w
)
{
{
datum
krec
,
drec
;
datum
krec
,
drec
;
const
char
*
failmsg
=
"gdbm mappings have bytes or string indices only"
;
if
(
!
PyArg_Parse
(
v
,
"s#"
,
&
krec
.
dptr
,
&
krec
.
dsize
)
)
{
if
(
!
parse_datum
(
v
,
&
krec
,
failmsg
))
{
PyErr_SetString
(
PyExc_TypeError
,
"gdbm mappings have bytes or string indices only"
);
return
-
1
;
return
-
1
;
}
}
if
(
dp
->
di_dbm
==
NULL
)
{
if
(
dp
->
di_dbm
==
NULL
)
{
...
@@ -196,9 +216,7 @@ dbm_ass_sub(dbmobject *dp, PyObject *v, PyObject *w)
...
@@ -196,9 +216,7 @@ dbm_ass_sub(dbmobject *dp, PyObject *v, PyObject *w)
}
}
}
}
else
{
else
{
if
(
!
PyArg_Parse
(
w
,
"s#"
,
&
drec
.
dptr
,
&
drec
.
dsize
))
{
if
(
!
parse_datum
(
w
,
&
drec
,
failmsg
))
{
PyErr_SetString
(
PyExc_TypeError
,
"gdbm mappings have bytes or string elements only"
);
return
-
1
;
return
-
1
;
}
}
errno
=
0
;
errno
=
0
;
...
...
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