help / color / mirror / code / Atom feed
From: donoban@riseup.net
To: zsh-workers@zsh.org
Subject: Segfault due short overflow in hist.c
Date: Sun, 12 Feb 2023 09:46:46 +0000	[thread overview]
Message-ID: <33435f346a37b44de507e41edf2839ff@riseup.net> (raw)


I noticed that after expanding a big directory with 'rm -fr *' I could
crash zsh in a reproducible way. Here is the backtrace from gdb:

(gdb) bt
#0  0x00005555555aa8be in hend (prog=prog@entry=0x7ffff7a5fbc8) at
#1  0x00005555555ab08f in loop (justonce=<optimized out>,
toplevel=<optimized out>) at init.c:170
#2  0x00005555555afacf in zsh_main (argc=<optimized out>,
argv=<optimized out>) at init.c:1794
#3  0x00007ffff7f809ca in libc_start_main_stage2 (main=0x55555556ad90
<main>, argc=1, argv=0x7fffffffe8c8) at src/env/__libc_start_main.c:95
#4  0x000055555556adab in _start ()

It seems that *chwords overflows with long enough strings so then it
tries to access a negative index in chline[].

I'm not sure of how it should it be properly fixed without breaking any
parts. Probably chwords should be a different type like size_t, but also
it needs some check for the next overflow scenario.

Best Regards!

                 reply	other threads:[~2023-02-12  9:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=33435f346a37b44de507e41edf2839ff@riseup.net \
    --to=donoban@riseup.net \
    --cc=zsh-workers@zsh.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).