[Devel] [PATCH] zdtm: fix package memory allocation in autofs.c
Stanislav Kinsburskiy
skinsbursky at virtuozzo.com
Thu Aug 31 12:10:40 MSK 2017
Plus some cleanup.
https://jira.sw.ru/browse/PSBM-71078
Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
---
test/zdtm/static/autofs.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/test/zdtm/static/autofs.c b/test/zdtm/static/autofs.c
index 8d917ee..882289f 100644
--- a/test/zdtm/static/autofs.c
+++ b/test/zdtm/static/autofs.c
@@ -460,10 +460,10 @@ static int automountd_loop(int pipe, const char *mountpoint, struct autofs_param
{
union autofs_v5_packet_union *packet;
ssize_t bytes;
- size_t psize = sizeof(*packet) * 2;
+ size_t psize = sizeof(*packet);
int err = 0;
- packet = malloc(psize);
+ packet = malloc(psize * 2);
if (!packet) {
pr_err("failed to allocate autofs packet\n");
return -ENOMEM;
@@ -473,7 +473,7 @@ static int automountd_loop(int pipe, const char *mountpoint, struct autofs_param
siginterrupt(SIGUSR2, 1);
while (!stop && !err) {
- memset(packet, 0, sizeof(*packet));
+ memset(packet, 0, psize * 2);
bytes = read(pipe, packet, psize);
if (bytes < 0) {
@@ -483,12 +483,12 @@ static int automountd_loop(int pipe, const char *mountpoint, struct autofs_param
}
continue;
}
- if (bytes > psize) {
- pr_err("read more that expected: %zd > %zd\n", bytes, psize);
- return -EINVAL;
- }
- if (bytes != sizeof(*packet)) {
- pr_err("read less than expected: %zd\n", bytes);
+ if (bytes != psize) {
+ pr_err("read %s that expected: %zd %s %zd\n",
+ (bytes > psize) ? "more" : "less",
+ bytes,
+ (bytes > psize) ? ">" : "<",
+ psize);
return -EINVAL;
}
err = automountd_serve(mountpoint, param, packet);
More information about the Devel
mailing list