Re: [Devel] [PATCH] zdtm: fix package memory allocation in autofs.c

2017-09-12 Thread Stanislav Kinsburskiy
No, we don't.
But this one could be applied: "tests: do not try to read more than packet in 
AutoFS test"

09.09.2017 02:01, Andrei Vagin пишет:
> On Thu, Aug 31, 2017 at 12:10:40PM +0300, Stanislav Kinsburskiy wrote:
>> Plus some cleanup.
> 
> Do we need this patch for the upstream criu? Could you send it to
> the criu mailing list?
> 
>>
>> https://jira.sw.ru/browse/PSBM-71078
>>
>> Signed-off-by: Stanislav Kinsburskiy 
>> ---
>>  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);
>>
>> ___
>> Devel mailing list
>> Devel@openvz.org
>> https://lists.openvz.org/mailman/listinfo/devel
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


Re: [Devel] [PATCH] zdtm: fix package memory allocation in autofs.c

2017-09-08 Thread Andrei Vagin
On Thu, Aug 31, 2017 at 12:10:40PM +0300, Stanislav Kinsburskiy wrote:
> Plus some cleanup.

Do we need this patch for the upstream criu? Could you send it to
the criu mailing list?

> 
> https://jira.sw.ru/browse/PSBM-71078
> 
> Signed-off-by: Stanislav Kinsburskiy 
> ---
>  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);
> 
> ___
> Devel mailing list
> Devel@openvz.org
> https://lists.openvz.org/mailman/listinfo/devel
___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel


[Devel] [PATCH] zdtm: fix package memory allocation in autofs.c

2017-08-31 Thread Stanislav Kinsburskiy
Plus some cleanup.

https://jira.sw.ru/browse/PSBM-71078

Signed-off-by: Stanislav Kinsburskiy 
---
 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);

___
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel