lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5629c8df-7ed7-d825-01d9-7b2ed7fbd042@gmail.com>
Date:   Fri, 11 Sep 2020 10:05:47 +0200
From:   "Michael Kerrisk (man-pages)" <mtk.manpages@...il.com>
To:     Alejandro Colomar <colomar.6.4.3@...il.com>
Cc:     mtk.manpages@...il.com, linux-man@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 15/24] unix.7: Use sizeof() to get buffer size (instead of
 hardcoding macro name)

On 9/10/20 11:13 PM, Alejandro Colomar wrote:
> Signed-off-by: Alejandro Colomar <colomar.6.4.3@...il.com>

Thanks, Alex. Patch Applied.

Cheers,

Michael


> ---
>  man7/unix.7 | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/man7/unix.7 b/man7/unix.7
> index f61b51424..50828a5bc 100644
> --- a/man7/unix.7
> +++ b/man7/unix.7
> @@ -991,7 +991,7 @@ main(int argc, char *argv[])
>  
>              /* Wait for next data packet. */
>  
> -            ret = read(data_socket, buffer, BUFFER_SIZE);
> +            ret = read(data_socket, buffer, sizeof(buffer));
>              if (ret == \-1) {
>                  perror("read");
>                  exit(EXIT_FAILURE);
> @@ -999,16 +999,16 @@ main(int argc, char *argv[])
>  
>              /* Ensure buffer is 0\-terminated. */
>  
> -            buffer[BUFFER_SIZE \- 1] = 0;
> +            buffer[sizeof(buffer) \- 1] = 0;
>  
>              /* Handle commands. */
>  
> -            if (!strncmp(buffer, "DOWN", BUFFER_SIZE)) {
> +            if (!strncmp(buffer, "DOWN", sizeof(buffer))) {
>                  down_flag = 1;
>                  break;
>              }
>  
> -            if (!strncmp(buffer, "END", BUFFER_SIZE)) {
> +            if (!strncmp(buffer, "END", sizeof(buffer))) {
>                  break;
>              }
>  
> @@ -1020,7 +1020,7 @@ main(int argc, char *argv[])
>          /* Send result. */
>  
>          sprintf(buffer, "%d", result);
> -        ret = write(data_socket, buffer, BUFFER_SIZE);
> +        ret = write(data_socket, buffer, sizeof(buffer));
>          if (ret == \-1) {
>              perror("write");
>              exit(EXIT_FAILURE);
> @@ -1116,7 +1116,7 @@ main(int argc, char *argv[])
>  
>      /* Receive result. */
>  
> -    ret = read(data_socket, buffer, BUFFER_SIZE);
> +    ret = read(data_socket, buffer, sizeof(buffer));
>      if (ret == \-1) {
>          perror("read");
>          exit(EXIT_FAILURE);
> @@ -1124,7 +1124,7 @@ main(int argc, char *argv[])
>  
>      /* Ensure buffer is 0\-terminated. */
>  
> -    buffer[BUFFER_SIZE \- 1] = 0;
> +    buffer[sizeof(buffer) \- 1] = 0;
>  
>      printf("Result = %s\en", buffer);
>  
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ