libSegFault: Fix printing signal number [BZ #27249]

Message ID 20210201200408.1030278-1-vt@altlinux.org
State Committed
Commit f9be44c7e6d90cb1fe3a0fbe3cc299ac783f0be8
Headers
Series libSegFault: Fix printing signal number [BZ #27249] |

Commit Message

Vitaly Chikunov Feb. 1, 2021, 8:04 p.m. UTC
  Signal number is written into the tail of buf, but printed from the
beginning, outputting garbage on the screen. Print from the correct
position.
---
 debug/segfault.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Adhemerval Zanella Feb. 1, 2021, 9 p.m. UTC | #1
On 01/02/2021 17:04, Vitaly Chikunov wrote:
> Signal number is written into the tail of buf, but printed from the
> beginning, outputting garbage on the screen. Print from the correct
> position.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  debug/segfault.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/debug/segfault.c b/debug/segfault.c
> index 0a6be8b9d4..1873022db9 100644
> --- a/debug/segfault.c
> +++ b/debug/segfault.c
> @@ -58,7 +58,7 @@ write_strsignal (int fd, int signal)
>    char buf[30];
>    char *ptr = _itoa_word (signal, &buf[sizeof (buf)], 10, 0);
>    WRITE_STRING ("signal ");
> -  write (fd, buf, &buf[sizeof (buf)] - ptr);
> +  write (fd, ptr, &buf[sizeof (buf)] - ptr);
>  }
>  
>  
>
  
Dmitry V. Levin Feb. 2, 2021, 12:37 a.m. UTC | #2
On Mon, Feb 01, 2021 at 06:00:30PM -0300, Adhemerval Zanella via Libc-alpha wrote:
> On 01/02/2021 17:04, Vitaly Chikunov wrote:
> > Signal number is written into the tail of buf, but printed from the
> > beginning, outputting garbage on the screen. Print from the correct
> > position.
> 
> LGTM, thanks.
> 
> Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

Applied, thanks!

> > ---
> >  debug/segfault.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/debug/segfault.c b/debug/segfault.c
> > index 0a6be8b9d4..1873022db9 100644
> > --- a/debug/segfault.c
> > +++ b/debug/segfault.c
> > @@ -58,7 +58,7 @@ write_strsignal (int fd, int signal)
> >    char buf[30];
> >    char *ptr = _itoa_word (signal, &buf[sizeof (buf)], 10, 0);
> >    WRITE_STRING ("signal ");
> > -  write (fd, buf, &buf[sizeof (buf)] - ptr);
> > +  write (fd, ptr, &buf[sizeof (buf)] - ptr);
> >  }
  

Patch

diff --git a/debug/segfault.c b/debug/segfault.c
index 0a6be8b9d4..1873022db9 100644
--- a/debug/segfault.c
+++ b/debug/segfault.c
@@ -58,7 +58,7 @@  write_strsignal (int fd, int signal)
   char buf[30];
   char *ptr = _itoa_word (signal, &buf[sizeof (buf)], 10, 0);
   WRITE_STRING ("signal ");
-  write (fd, buf, &buf[sizeof (buf)] - ptr);
+  write (fd, ptr, &buf[sizeof (buf)] - ptr);
 }