chiark / gitweb /
Make PrivateTmp dirs also inaccessible from the outside
[elogind.git] / src / libudev / libudev-util.c
index 2eb7907063bc41f098d27fa4199fa7b4cff6ae97..44f6e4a863b1df1f4f2bef99b5fb762fbb327e8c 100644 (file)
@@ -83,7 +83,7 @@ uid_t util_lookup_user(struct udev *udev, const char *user)
         size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
         char *buf = alloca(buflen);
 
-        if (strcmp(user, "root") == 0)
+        if (streq(user, "root"))
                 return 0;
         uid = strtoul(user, &endptr, 10);
         if (endptr[0] == '\0')
@@ -108,7 +108,7 @@ gid_t util_lookup_group(struct udev *udev, const char *group)
         size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
         char *buf = NULL;
 
-        if (strcmp(group, "root") == 0)
+        if (streq(group, "root"))
                 return 0;
         gid = strtoul(group, &endptr, 10);
         if (endptr[0] == '\0')
@@ -568,7 +568,7 @@ err:
  * Murmurhash is under the MIT license.
  *
  */
-static unsigned int murmur_hash2(const char *key, int len, unsigned int seed)
+static unsigned int murmur_hash2(const char *key, size_t len, unsigned int seed)
 {
         /*
          *  'm' and 'r' are mixing constants generated offline.
@@ -583,17 +583,18 @@ static unsigned int murmur_hash2(const char *key, int len, unsigned int seed)
         /* mix 4 bytes at a time into the hash */
         const unsigned char * data = (const unsigned char *)key;
 
-        while(len >= 4) {
-                unsigned int k = *(unsigned int *)data;
+        while(len >= sizeof(unsigned int)) {
+                unsigned int k;
 
+                memcpy(&k, data, sizeof(k));
                 k *= m;
                 k ^= k >> r;
                 k *= m;
                 h *= m;
                 h ^= k;
 
-                data += 4;
-                len -= 4;
+                data += sizeof(k);
+                len -= sizeof(k);
         }
 
         /* handle the last few bytes of the input array */