[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] tests: fix getpwnam and getgrnam
From: |
Lukáš Zaoral |
Subject: |
[PATCH] tests: fix getpwnam and getgrnam |
Date: |
Mon, 10 Jun 2024 16:40:09 +0200 |
The calls to these functions would always fail because the size of the buffer
was smaller than the minimum (170000) specified in the test implementations
of getgrnam_r and getpwnam_r. Use test_get*_match directly because getpwnam
and getgrnam should never fail on ERANGE.
This commit fixes the following failure in the test/root/restore.test test:
[21] $ chown bin passwd -- failed
chown: invalid user: ‘bin’ != ~
Fixes: 3737f000d3f17cd283f51eeacac21a71a3472053 ("use thread-safe getpwnam_r
and getgrnam_r")
---
test/test_group.c | 2 +-
test/test_passwd.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/test/test_group.c b/test/test_group.c
index 96dd612..42d6b07 100644
--- a/test/test_group.c
+++ b/test/test_group.c
@@ -136,7 +136,7 @@ struct group *getgrnam(const char *name)
static struct group grp;
struct group *result;
- (void) getgrnam_r(name, &grp, buf, sizeof(buf), &result);
+ (void) test_getgr_match(&grp, buf, sizeof buf, &result, match_name,
name);
return result;
}
diff --git a/test/test_passwd.c b/test/test_passwd.c
index b88ea45..ebe9dce 100644
--- a/test/test_passwd.c
+++ b/test/test_passwd.c
@@ -117,7 +117,7 @@ int getpwnam_r(const char *name, struct passwd *pwd, char
*buf, size_t buflen,
*result = NULL;
return ERANGE;
}
- last_buflen =- 1;
+ last_buflen = -1;
return test_getpw_match(pwd, buf, buflen, result, match_name, name);
}
@@ -129,7 +129,7 @@ struct passwd *getpwnam(const char *name)
static struct passwd pwd;
struct passwd *result;
- (void) getpwnam_r(name, &pwd, buf, sizeof(buf), &result);
+ (void) test_getpw_match(&pwd, buf, sizeof(buf), &result, match_name,
name);
return result;
}
--
2.45.2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] tests: fix getpwnam and getgrnam,
Lukáš Zaoral <=