You are not logged in.

#1 2020-04-25 22:31:00

101110V
Member
Registered: 2018-11-09
Posts: 1

[nano4.9.2-1] Justify option segfault

I can't seem to reproduce this on at least one other distribution, so it seems (at least somewhat) Arch-related.
AFAIK x86_64 seems to be affected. Furthermore, I'm only reporting this as it seems to affect multiple of my machines.

Here's a handcrafted shell script which (quite) randomly generates about 90% positive results (assuming /tmp/ is rw):

#!/bin/bash
count=1
rcount=0
dest_dir=/tmp/
filename=sample.txt
test -e $dest_dir.pos || echo 1 > $dest_dir.pos
test -e $dest_dir.tot || echo 1 > $dest_dir.tot
pos=$(cat $dest_dir.pos)
tot=$(cat $dest_dir.tot)
percent=$[$[$pos*100]/$tot]%
cond0=$[RANDOM%100001+1]
cond0cond=$[RANDOM%2]
cond10=$[RANDOM%170+1]
cond12=$[RANDOM%100001+1]
cond12cond=$[RANDOM%2]
cond20=$[RANDOM%47+1]
cond30=$[RANDOM%100000+2]
cond40=$[RANDOM%100001+1]
if ((($cond0cond) == ($[RANDOM%2]))); then
head /dev/urandom | tr -dc '\n' | head -c $cond0 > $dest_dir$filename
((count++))
fi
if ((($cond12cond) == ($[RANDOM%2]))) && ((($count) == 1)); then
head /dev/urandom | tr -dc '[[:print:]]' | tr -dc '! ' | head -c $cond12 | sed -E "s/$/\n\n/g" > $dest_dir$filename
head /dev/urandom | tr -dc '[[:print:]]' | head -c $cond10 | sed -E "s/^(\!|[ ]|>|:|}|#|\||;|%)/$(head /dev/urandom | tr -d '! >:}#|;%' | tr -dc '[[:print:]]' | head -c 1 | sed -E 's/(\"|\/|\\|\^|\$|`)/\\\1/g')/g" | sed -E "s/$/\n/g" >> $dest_dir$filename
elif ((($cond12cond) == ($[RANDOM%2]))) && ((($count) == 2)); then
head /dev/urandom | tr -dc '[[:print:]]' | tr -dc '! ' | head -c $cond12 | sed -E "s/$/\n\n/g" >> $dest_dir$filename
head /dev/urandom | tr -dc '[[:print:]]' | head -c $cond10 | sed -E "s/^(\!|[ ]|>|:|}|#|\||;|%)/$(head /dev/urandom | tr -d '! >:}#|;%' | tr -dc '[[:print:]]' | head -c 1 | sed -E 's/(\"|\/|\\|\^|\$|`)/\\\1/g')/g" | sed -E "s/$/\n/g" >> $dest_dir$filename
else
head /dev/urandom | tr -dc '[[:print:]]' | head -c $cond10 | sed -E "s/^(\!|[ ]|>|:|}|#|\||;|%)/$(head /dev/urandom | tr -d '! >:}#|;%' | tr -dc '[[:print:]]' | head -c 1 | sed -E 's/(\"|\/|\\|\^|\$|`)/\\\1/g')/g" | sed -E "s/$/\n/g" > $dest_dir$filename
fi
head /dev/urandom | tr -dc '[[:print:]]' | head -c $cond20 | sed -E "s/^(\!|[ ]|>|:|}|#|\||;|%)/$(head /dev/urandom | tr -d '! >:}#|;%' | tr -dc '[[:print:]]' | head -c 1 | sed -E 's/(\"|\/|\\|\^|\$|`)/\\\1/g')/g" | sed -E "s/$/\n/g" >> $dest_dir$filename
head /dev/urandom | tr -dc '[[:print:]]' | head -c $cond30 | sed -E "s/^.(\!|>|:|}|#|\||;|%)/$(head /dev/urandom | tr -d '!>:}#|;%' | tr -dc '[[:print:]]' | head -c 1 | sed -E 's/(\"|\/|\\|\^|\$|`)/\\\1/g')/g" | sed -E "s/$/\n/g" | sed -E "s/^[^ ]/ /g" >> $dest_dir$filename
head /dev/urandom | tr -dc '[[:print:]]' | head -c $cond40 | sed -E "s/^(\!|[ ]|>|:|}|#|\||;|%)/$(head /dev/urandom | tr -d '! >:}#|;%' | tr -dc '[[:print:]]' | head -c 1 | sed -E 's/(\"|\/|\\|\^|\$|`)/\\\1/g')/g" | sed -E "s/$/\n/g" >> $dest_dir$filename
#echo "Please try to justify the following file..." && sleep 3
nano --ignorercfiles $dest_dir$filename
if (("$?" == 0)); then
((tot++)); echo $tot > $dest_dir.tot
echo -e "Seems like the script doesn't always generate positive results.\nYour current success rate is $percent.\n Sorry for the inconvenience.\n Please try again.\n"
elif (("$?" == 1)); then
((pos++)); ((tot++)); echo $pos > $dest_dir.pos; echo $tot > $dest_dir.tot; echo -e "Your current success rate is $percent.\n"
else
echo "Orphan exit code: $?; success rate unchanged."
fi
exit 0

For generating a core dump, please define NANO_NOCATCH.

TLDR; Basically, any file initialized with the following pattern, with some limitations, will crash Nano when justifying (ALT+J) on Arch:

x
x
 x
x

Offline

Board footer

Powered by FluxBB