diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2008-07-04 19:53:47 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2008-07-04 19:53:47 +0200 |
| commit | ccf689a426760a69b77394abbcddf7897cbd6488 (patch) | |
| tree | 2756e67e713b1463a66ca1b7b8c1e0f966ac0e23 /python | |
| parent | 65871e1fea624ad7c78001cf0e0c3e8bc7352283 (diff) | |
| download | python-apt-ccf689a426760a69b77394abbcddf7897cbd6488.tar.gz | |
* python/apt_pkgmodule.cc:
- fix bug in hashsum calculation when the original string
contains \0 charackters (thanks to Celso Providelo and
Ryan Hass for the test-case) LP: #243630
Diffstat (limited to 'python')
| -rw-r--r-- | python/apt_pkgmodule.cc | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index ae1cf7be..dea34958 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -175,8 +175,11 @@ static PyObject *md5sum(PyObject *Self,PyObject *Args) // Digest of a string. if (PyString_Check(Obj) != 0) { + char *s; + Py_ssize_t len; MD5Summation Sum; - Sum.Add(PyString_AsString(Obj)); + PyString_AsStringAndSize(Obj, &s, &len); + Sum.Add((const unsigned char*)s, len); return CppPyString(Sum.Result().Value()); } @@ -212,8 +215,10 @@ static PyObject *sha1sum(PyObject *Self,PyObject *Args) // Digest of a string. if (PyString_Check(Obj) != 0) { + char *s; + Py_ssize_t len; SHA1Summation Sum; - Sum.Add(PyString_AsString(Obj)); + Sum.Add((const unsigned char*)s, len); return CppPyString(Sum.Result().Value()); } @@ -249,8 +254,11 @@ static PyObject *sha256sum(PyObject *Self,PyObject *Args) // Digest of a string. if (PyString_Check(Obj) != 0) { + char *s; + Py_ssize_t len; SHA256Summation Sum; - Sum.Add(PyString_AsString(Obj)); + PyString_AsStringAndSize(Obj, &s, &len); + Sum.Add((const unsigned char*)s, len); return CppPyString(Sum.Result().Value()); } |
