pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/3abf26778782879ef50561e851dbc751d9888806

l="stylesheet" href="https://github.githubassets.com/assets/global-d18f184ea1a06a2c.css" /> [3.11] gh-116447: Fix possible UB in `arraymodule` and `getargs` (GH-… · python/cpython@3abf267 · GitHub
Skip to content

Commit 3abf267

Browse files
[3.11] gh-116447: Fix possible UB in arraymodule and getargs (GH-116459) (#116497)
gh-116447: Fix possible UB in `arraymodule` and `getargs` (GH-116459) (cherry picked from commit fdb2d90) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
1 parent 0f6cd29 commit 3abf267

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

Modules/arraymodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ BB_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
244244
if (!PyArg_Parse(v, "b;array item must be integer", &x))
245245
return -1;
246246
if (i >= 0)
247-
((char *)ap->ob_item)[i] = x;
247+
((unsigned char *)ap->ob_item)[i] = x;
248248
return 0;
249249
}
250250

Python/getargs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
672672
switch (c) {
673673

674674
case 'b': { /* unsigned byte -- very short int */
675-
char *p = va_arg(*p_va, char *);
675+
unsigned char *p = va_arg(*p_va, unsigned char *);
676676
long ival = PyLong_AsLong(arg);
677677
if (ival == -1 && PyErr_Occurred())
678678
RETURN_ERR_OCCURRED;
@@ -693,7 +693,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
693693

694694
case 'B': {/* byte sized bitfield - both signed and unsigned
695695
values allowed */
696-
char *p = va_arg(*p_va, char *);
696+
unsigned char *p = va_arg(*p_va, unsigned char *);
697697
unsigned long ival = PyLong_AsUnsignedLongMask(arg);
698698
if (ival == (unsigned long)-1 && PyErr_Occurred())
699699
RETURN_ERR_OCCURRED;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy