diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-09-30 13:55:30 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-09-30 13:55:30 +0200 |
commit | 1904cd9dda6dadf396c1f28031346bdc035d420d (patch) | |
tree | ca0b9c637e5554446b6266b255c9e303407d3d7b /Python/getargs.c | |
parent | 9a9e274a15370bb90a4856f9dabbc512fe565ce8 (diff) | |
parent | 8d799851fb876c167930eed7d0b23fada08a08d8 (diff) | |
download | cpython-1904cd9dda6dadf396c1f28031346bdc035d420d.tar.gz |
(Merge 3.4) faulthandler: test_gil_released() now uses _sigsegv() instead of
_read_null(), because _read_null() cannot be used on AIX. On AIX, reading from
NULL is allowed: the first page of memory is a mapped read-only on AIX.
_read_null() and _sigabrt() don't accept parameters.
Diffstat (limited to 'Python/getargs.c')
-rw-r--r-- | Python/getargs.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/Python/getargs.c b/Python/getargs.c index 946faf2d7e..c749bb643c 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -872,10 +872,10 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, STORE_SIZE(count); format++; } else { - if (strlen(*p) != count) - return converterr( - "bytes without null bytes", - arg, msgbuf, bufsize); + if (strlen(*p) != (size_t)count) { + PyErr_SetString(PyExc_ValueError, "embedded null byte"); + RETURN_ERR_OCCURRED; + } } break; } @@ -948,16 +948,15 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, if (sarg == NULL) return converterr(CONV_UNICODE, arg, msgbuf, bufsize); + if (strlen(sarg) != (size_t)len) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + RETURN_ERR_OCCURRED; + } *p = sarg; } else return converterr(c == 'z' ? "str or None" : "str", arg, msgbuf, bufsize); - if (*p != NULL && sarg != NULL && (Py_ssize_t) strlen(*p) != len) - return converterr( - c == 'z' ? "str without null characters or None" - : "str without null characters", - arg, msgbuf, bufsize); } break; } @@ -994,10 +993,10 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags, *p = PyUnicode_AsUnicodeAndSize(arg, &len); if (*p == NULL) RETURN_ERR_OCCURRED; - if (Py_UNICODE_strlen(*p) != len) - return converterr( - "str without null characters or None", - arg, msgbuf, bufsize); + if (Py_UNICODE_strlen(*p) != (size_t)len) { + PyErr_SetString(PyExc_ValueError, "embedded null character"); + RETURN_ERR_OCCURRED; + } } else return converterr(c == 'Z' ? "str or None" : "str", arg, msgbuf, bufsize); |