summaryrefslogtreecommitdiffstats
path: root/src/python
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2015-11-19 13:07:52 +0000
committerLukas Slebodnik <lslebodn@redhat.com>2016-01-29 09:32:13 +0100
commit2ff8131cf02decaf0dd0754e843732fe7774fc59 (patch)
tree80dccca68ce15b50ed3ca789fcd96734c2504bb5 /src/python
parentd3f14ed93ef61268d0a68898ed9c44b4f773081c (diff)
downloadsssd-2ff8131cf02decaf0dd0754e843732fe7774fc59.tar.gz
sssd-2ff8131cf02decaf0dd0754e843732fe7774fc59.tar.xz
sssd-2ff8131cf02decaf0dd0754e843732fe7774fc59.zip
pysss_murmur: Fix warning Wsign-compare
src/python/pysss_murmur.c: In function ‘py_murmurhash3’: src/python/pysss_murmur.c:47:17: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] key_len > strlen(key)) { ^ uint32_t murmurhash3(const char *key, int len, uint32_t seed) The second argument of the function murmurhash3 has type int. But the code expects to be unsigned integer. There is code in python wrapper py_murmurhash3 which check boundaries of that argument. It should be an unsigned "key_len > INT_MAX || key_len < 0". An exception should be thrown for negative number. Moreover, the length should be shorter then a length of input string. The strlen returns size_t which is unsigned and key_len is signed long. We already checked that value is unsigned so we can safely cast key_len to size_t Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src/python')
-rw-r--r--src/python/pysss_murmur.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/python/pysss_murmur.c b/src/python/pysss_murmur.c
index 97d752b2a..b14a67202 100644
--- a/src/python/pysss_murmur.c
+++ b/src/python/pysss_murmur.c
@@ -44,7 +44,7 @@ static PyObject * py_murmurhash3(PyObject *module, PyObject *args)
}
if (seed > UINT32_MAX || key_len > INT_MAX || key_len < 0 ||
- key_len > strlen(key)) {
+ (size_t)key_len > strlen(key)) {
PyErr_Format(PyExc_ValueError, "Invalid value\n");
return NULL;
}