mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
[3.12] gh-116447: Fix possible UB in arraymodule
and getargs
(GH-116459) (#116496)
gh-116447: Fix possible UB in `arraymodule` and `getargs` (GH-116459)
(cherry picked from commit fdb2d90a27
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
This commit is contained in:
parent
a8a95135a2
commit
2647afeab6
2 changed files with 3 additions and 3 deletions
|
@ -672,7 +672,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
switch (c) {
|
||||
|
||||
case 'b': { /* unsigned byte -- very short int */
|
||||
char *p = va_arg(*p_va, char *);
|
||||
unsigned char *p = va_arg(*p_va, unsigned char *);
|
||||
long ival = PyLong_AsLong(arg);
|
||||
if (ival == -1 && PyErr_Occurred())
|
||||
RETURN_ERR_OCCURRED;
|
||||
|
@ -693,7 +693,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
|
|||
|
||||
case 'B': {/* byte sized bitfield - both signed and unsigned
|
||||
values allowed */
|
||||
char *p = va_arg(*p_va, char *);
|
||||
unsigned char *p = va_arg(*p_va, unsigned char *);
|
||||
unsigned long ival = PyLong_AsUnsignedLongMask(arg);
|
||||
if (ival == (unsigned long)-1 && PyErr_Occurred())
|
||||
RETURN_ERR_OCCURRED;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue