Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Edward Huff Newsgroups: gnu.bash.bug Subject: history -r a; history -c; history -r b gives segfault Date: Sun, 10 Jun 2018 03:28:11 -0400 Lines: 56 Approved: bug-bash@gnu.org Message-ID: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1528615697 5895 208.118.235.17 (10 Jun 2018 07:28:17 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=gklKmUIEw8z6JIg2gF2bLWFs38l+owz62H04CcnAaYg=; b=ktNnM4K9ny0FB8t52R33zUnhF+pSZHkQn1TJMo6FP2OqMN1neBOIUK9N36Y/dvUX5o OzoLZste12bnnuR4zRFRAK6HWiwzye+ZDhcH722RqMwe3kf0T72GL0JvcjmNxWklKhIw UmcIQSADPuVsJDYOlXQZ50/mvXbt29r8xQRQfHJ3m/WyL72qzTJxYJMqc4NSQgPx+C5Z YOmvowI+Z4jnHcuWVsbWu5FwXKhMf3Bb09DbrRegK+KEYwHBzv4xgbrgxqp7mHV48/J5 t0n7jbK0Z0hDz+EtOuAOkHOEJXnwz+QNx50ff4pX/db17UFJ/GskB5F+rmJeBgYT3C3v gzEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=gklKmUIEw8z6JIg2gF2bLWFs38l+owz62H04CcnAaYg=; b=NN9IxN0O6Oje2Fh82FafWUeWGcbMbMcxI5DEizTjN7hJr17c18OczmC0BWqTf8CR// 6/P7opEKRp5ye/GmOdDo4wcRq4QfSApzbDyA2nW1a4VNgHOgl0tKDBluaiuQmdB7wx1t hX+pWr53LZvfvrVnrMbjZeLnm4X8JNqelGQDzLeUjnGsxprpAHKNfY6g6GvXDtCK8s4a 4V8OhEOrDzgYrvp8PEKbxun0eUhK4cXvH8hJH21MMqmqiSfjYtry5x+pPXUapn3Ed8mD 8LS0D+ITML+mGJayg45LRzvxerYsPE9befSI03Rl6J/xhTmChfdfDe7fKoMuGeB4IoQC gfdA== X-Gm-Message-State: APt69E23czziy4UHVgqqWiEp782kPXCyrB03wO0kaTk3aHg4WFppz1q5 z3r5i44VyTEYgQ1QgCO367cCATbs9IY3OcPUMkoPego= X-Google-Smtp-Source: ADUXVKLjMLyAGv+x9lC7RXMPMXmC1U1Yzs/0mwWjI2WuXY6iq+uMaCcQHMFwwprcRRytReYkPxsqVZnHCVdAgBHq7u0= X-Received: by 2002:a6b:3ce:: with SMTP id e75-v6mr11130955ioi.194.1528615691787; Sun, 10 Jun 2018 00:28:11 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c06::229 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14227 Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_GNU_SOURCE -DRECYCLES_PIDS -DDEFAULT_PATH_VALUE='/usr/local/bin:/usr/bin' -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -mcet -fcf-protection -Wno-parentheses -Wno-format-security uname output: Linux elite.mainst 4.16.12-300.fc28.x86_64 #1 SMP Fri May 25 21:13:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-redhat-linux-gnu Bash Version: 4.4 Patch Level: 19 Release Status: release Description: Segfault from reading a history file not starting with # with HISTTIMEFORMAT set and history_multiline_entries nonzero and with the history cleared and read on the same input line. Repeat-By: env -i bash --noprofile --norc echo $'#1\necho a'>a echo 'echo b'>b HISTTIMEFORMAT='%s ' history -r a # force history_multiline_entries to be nonzero history -c; history -r b # force history_length to be zero when reading Segmentation fault (core dumped) Fix: history_multiline_entries probably shouldn't be sticky over unset HISTTIMEFORMAT, but here is the minimal fix: --- /usr/src/debug/bash-4.4.19-2.fc28.x86_64/lib/readline/histfile.c 2016-01-25 10:34:03.000000000 -0500 +++ histfile.c 2018-06-10 03:12:17.750218417 -0400 @@ -385,7 +385,7 @@ { if (HIST_TIMESTAMP_START(line_start) == 0) { - if (last_ts == NULL && history_multiline_entries) + if (history_length > 0 && last_ts == NULL && history_multiline_entries) _hs_append_history_line (history_length - 1, line_start); else add_history (line_start);