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
1ce46d99
Kaydet (Commit)
1ce46d99
authored
Haz 23, 2013
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #11016: Detect integer conversion on conversion from Python int to C mode_t
üst
42471ad7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
13 deletions
+27
-13
_stat.c
Modules/_stat.c
+27
-13
No files found.
Modules/_stat.c
Dosyayı görüntüle @
1ce46d99
...
...
@@ -258,15 +258,32 @@ typedef unsigned short mode_t;
# define SF_SNAPSHOT 0x00200000
#endif
static
mode_t
_PyLong_AsMode_t
(
PyObject
*
op
)
{
unsigned
long
value
;
mode_t
mode
;
value
=
PyLong_AsUnsignedLong
(
op
);
if
((
value
==
(
unsigned
long
)
-
1
)
&&
PyErr_Occurred
())
return
(
mode_t
)
-
1
;
mode
=
(
mode_t
)
value
;
if
((
unsigned
long
)
mode
!=
value
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"mode out of range"
);
return
(
mode_t
)
-
1
;
}
return
mode
;
}
#define stat_S_ISFUNC(isfunc, doc) \
static PyObject * \
stat_ ##isfunc (PyObject *self, PyObject *omode) \
{ \
unsigned long mode = PyLong_AsUnsignedLong(omode);
\
if ((mode == (
unsigned long)-1) && PyErr_Occurred()) {
\
mode_t mode = _PyLong_AsMode_t(omode);
\
if ((mode == (
mode_t)-1) && PyErr_Occurred())
\
return NULL; \
} \
return PyBool_FromLong(isfunc(mode)); \
} \
PyDoc_STRVAR(stat_ ## isfunc ## _doc, doc)
...
...
@@ -318,10 +335,9 @@ PyDoc_STRVAR(stat_S_IMODE_doc,
static
PyObject
*
stat_S_IMODE
(
PyObject
*
self
,
PyObject
*
omode
)
{
unsigned
long
mode
=
PyLong_AsUnsignedLong
(
omode
);
if
((
mode
==
(
unsigned
long
)
-
1
)
&&
PyErr_Occurred
())
{
mode_t
mode
=
_PyLong_AsMode_t
(
omode
);
if
((
mode
==
(
mode_t
)
-
1
)
&&
PyErr_Occurred
())
return
NULL
;
}
return
PyLong_FromUnsignedLong
(
mode
&
S_IMODE
);
}
...
...
@@ -332,10 +348,9 @@ PyDoc_STRVAR(stat_S_IFMT_doc,
static
PyObject
*
stat_S_IFMT
(
PyObject
*
self
,
PyObject
*
omode
)
{
unsigned
long
mode
=
PyLong_AsUnsignedLong
(
omode
);
if
((
mode
==
(
unsigned
long
)
-
1
)
&&
PyErr_Occurred
())
{
mode_t
mode
=
_PyLong_AsMode_t
(
omode
);
if
((
mode
==
(
mode_t
)
-
1
)
&&
PyErr_Occurred
())
return
NULL
;
}
return
PyLong_FromUnsignedLong
(
mode
&
S_IFMT
);
}
...
...
@@ -395,12 +410,11 @@ static PyObject *
stat_filemode
(
PyObject
*
self
,
PyObject
*
omode
)
{
char
buf
[
10
];
unsigned
long
mode
;
mode_t
mode
;
mode
=
PyLong_AsUnsignedLong
(
omode
);
if
((
mode
==
(
unsigned
long
)
-
1
)
&&
PyErr_Occurred
())
{
mode
=
_PyLong_AsMode_t
(
omode
);
if
((
mode
==
(
mode_t
)
-
1
)
&&
PyErr_Occurred
())
return
NULL
;
}
buf
[
0
]
=
filetype
(
mode
);
fileperm
(
mode
,
&
buf
[
1
]);
...
...
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