1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-12-09 14:21:14 +03:00

Use uintptr_t instead of performing pointer subtraction with a null pointer

Signed-off-by: Qihao Chencao <twose@qq.com>

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
This commit is contained in:
Qihao Chencao
2022-06-28 16:57:55 +08:00
committed by Adhemerval Zanella
parent dab6344279
commit cc4d6614b5
12 changed files with 35 additions and 36 deletions

View File

@@ -142,7 +142,7 @@ __sha256_crypt_r (const char *key, const char *salt, char *buffer, int buflen)
salt_len = MIN (strcspn (salt, "$"), SALT_LEN_MAX);
key_len = strlen (key);
if ((key - (char *) 0) % __alignof__ (uint32_t) != 0)
if (((uintptr_t) key) % __alignof__ (uint32_t) != 0)
{
char *tmp;
@@ -157,20 +157,20 @@ __sha256_crypt_r (const char *key, const char *salt, char *buffer, int buflen)
key = copied_key =
memcpy (tmp + __alignof__ (uint32_t)
- (tmp - (char *) 0) % __alignof__ (uint32_t),
- ((uintptr_t) tmp) % __alignof__ (uint32_t),
key, key_len);
assert ((key - (char *) 0) % __alignof__ (uint32_t) == 0);
assert (((uintptr_t) key) % __alignof__ (uint32_t) == 0);
}
if ((salt - (char *) 0) % __alignof__ (uint32_t) != 0)
if (((uintptr_t) salt) % __alignof__ (uint32_t) != 0)
{
char *tmp = (char *) alloca (salt_len + __alignof__ (uint32_t));
alloca_used += salt_len + __alignof__ (uint32_t);
salt = copied_salt =
memcpy (tmp + __alignof__ (uint32_t)
- (tmp - (char *) 0) % __alignof__ (uint32_t),
- ((uintptr_t) tmp) % __alignof__ (uint32_t),
salt, salt_len);
assert ((salt - (char *) 0) % __alignof__ (uint32_t) == 0);
assert (((uintptr_t) salt) % __alignof__ (uint32_t) == 0);
}
#ifdef USE_NSS