diff options
author | Benjamin Peterson <benjamin@python.org> | 2019-12-17 00:39:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-17 00:39:57 (GMT) |
commit | 052f47ef5cc363e842e0e839980cfa55ada123b5 (patch) | |
tree | bf14554edc2ea804899b55d079a40099312a0e03 | |
parent | de4481339dec395d70e350aa2e22d7990d2b3635 (diff) | |
download | cpython-052f47ef5cc363e842e0e839980cfa55ada123b5.zip cpython-052f47ef5cc363e842e0e839980cfa55ada123b5.tar.gz cpython-052f47ef5cc363e842e0e839980cfa55ada123b5.tar.bz2 |
bpo-38730: Replace strncpy in import.c with memcpy. (GH-17633)
In all these cases, we know the exact length we want copied, so memcpy is the right function to use.
-rw-r--r-- | Python/import.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Python/import.c b/Python/import.c index ccbd949..b79354b 100644 --- a/Python/import.c +++ b/Python/import.c @@ -2456,7 +2456,7 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level) "Module name too long"); return NULL; } - strncpy(buf, start, len); + memcpy(buf, start, len); buf[len] = '\0'; pkgname = PyString_FromString(buf); if (pkgname == NULL) { @@ -2554,7 +2554,7 @@ load_next(PyObject *mod, PyObject *altmod, char **p_name, char *buf, "Module name too long"); return NULL; } - strncpy(p, name, len); + memcpy(p, name, len); p[len] = '\0'; *p_buflen = p+len-buf; @@ -2568,7 +2568,7 @@ load_next(PyObject *mod, PyObject *altmod, char **p_name, char *buf, Py_DECREF(result); return NULL; } - strncpy(buf, name, len); + memcpy(buf, name, len); buf[len] = '\0'; *p_buflen = len; } |