bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Segfault in save_bash_input. Array index is out of a range.


From: Alexey Makhalov
Subject: Segfault in save_bash_input. Array index is out of a range.
Date: Wed, 22 Jul 2015 14:00:54 -0700

I have met situation when nfd(returned by fcntl) is 217, but nbuffers is only 25

  if (buffers[nfd])
    {
      /* What's this?  A stray buffer without an associated open file
         descriptor?  Free up the buffer and report the error. */
      internal_error (_("save_bash_input: buffer already exists for new fd %d"), nfd);
      free_buffered_stream (buffers[nfd]);
    }
and free_buffered_stream() causes a segfault.

I added extra comparison nfd < nbuffers - it works for me.
Why do we need this check? Does stray buffer happen, when nfd is in a range [0,nbuffers)?

Patch is attached.

Thanks,
Alexey

Attachment: fix-save_bash_input-segfault.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]