bugGNU nano - Bugs: bug #24163, division by zero when entering...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #24163: division by zero when entering /home and others in read files browser

Submitter:  Jordi Mallach <jordi>
Submitted:  Sat 30 Aug 2008 11:31:05 AM UTC
   
 
Severity:  3 - Normal Status:  Fixed
Assigned to:  astyanax Open/Closed:  Closed

Jump to the original submission

Tue 27 Oct 2009 04:13:58 AM UTC, comment #7: 

okay this should be fixed in r4414.  I decided to set width in that instance where we're initializing with no files in the directory to use the value of 'longest' which should always be at least 15, I'd hate to get int some odd situation where we're dividing by longest but it's somehow 0 due to some overflow bug or insanely long file path.  Probably needless worry, but oh well.

Sorry I was not more help in helping you figure this elusive one, and I appreciate your dilligence in finding it!

Chris Allegretta <astyanax>
Group administrator
Sun 26 Jul 2009 11:35:26 PM UTC, comment #6: 

Ok, after some debugging of 2.1.10pre1 I found a fix/workaround:

<pabs> jordi: looking at the nano code, it seems that the COLS has to be a multiple of 15 for the crash to happen
<pabs> jordi: line 539 of browser.c seems to be the issue, it leaves width as zero, which causes the division by zero
<pabs> jordi: the 15 seems dir dependent
<pabs> jordi: ah, 15 is the length of the longest string in the list: ".. (parent dir)"
<pabs> jordi: two character patch (one in a comment): sed -i -e '537,539s_%_/_' src/browser.c

I don't know the code well enough to know if it is correct, but it seems to prevent crashes for me. I do also note that nano exits and won't start when there are 5 or less columns in the terminal window.

Paul Wise <pabs>
Sat 25 Jul 2009 05:36:05 PM UTC, comment #5: 

Chris, I've prepared a package of 2.1.10pre1 for pabs to test, and unfortunately the bug is still happening in his setup (not in mine). I hope we'll be able to find the culprit during this week while we both attend DebConf, in an attempt to be in time for a fix in 2.1.10.

Jordi Mallach <jordi>
Group administrator
Sun 31 Aug 2008 02:30:38 AM UTC, comment #4: 

I'm attaching /etc/nanorc ~/.nanorc and the output of export.

(file #16403, file #16404, file #16405)

Paul Wise <pabs>
Sat 30 Aug 2008 11:38:54 PM UTC, comment #3: 

Im not sure what debian is doing differently, but I've been unable to reproduce this behavior on both i386 or x86_64 entering or existing any directory.  Perhaps there is an environment variable I don't have set which is somehow affecting the issue?

I would be interested in getting the output of 'export' for sh or 'setenv' for csh in order to troubleshoot more, or some kind of repeatable test case.

Chris Allegretta <astyanax>
Group administrator
Sat 30 Aug 2008 11:33:30 AM UTC, comment #2: 

Sigh, I need more sleep today. The original report can be found here:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=496008

Jordi Mallach <jordi>
Group administrator
Sat 30 Aug 2008 11:32:32 AM UTC, comment #1: 

Ah, note Paul was using version 2.0.7-3 from Debian at the time.

Jordi Mallach <jordi>
Group administrator
Sat 30 Aug 2008 11:31:05 AM UTC, original submission:  

I recently got this report in the Debian BTS.
I haven't been able to reproduce, but notice the two extraneous characters included in the backtrace.

------------------------------------------------

Whenever I enter /home in the read files browser (Ctrl+r then Ctrl+t) I
get a floating point exception. It happens when I enter /home from
either / or /home/pabs. It also happens when entering /cdrom and /srv or
leaving /lib32. It also happens when nano is started up in /cdrom, /srv
or /home. The problem happens on both i386 and amd64. It happens for
both root and a normal user. The system-wide configuration is not
altered. Strangely it also happens with non-toplevel dirs named home or
srv or cdrom.

pabs@chianamo:~$ cd ~
pabs@chianamo:~$ pwd
/home/pabs
pabs@chianamo:~$ gdb nano
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...
(gdb) r

Ctrl+r
Ctrl+t
Enter

some debugging from nano recompiled with noopt nostrip:

(gdb) l
107     titlebar(path);
108
109     while (!abort) {
110 struct stat st;
111 int i;
112 size_t fileline = selected / width;
113 /* The line number the selected file is on. */
114 char *new_path;
115 /* The path we switch to at the "Go to Directory"
116 prompt. /
(gdb) p selected
$2 = 1
(gdb) p width
$1 = 0
(gdb) bt full
#0  0x000000000040389a in do_browser (path=0x13184e0 "/home/", dir=0x1317490) at ../../src/browser.c:112
        st = {st_dev = 65025, st_ino = 131073, st_nlink = 3, st_mode = 16877, st_uid = 0, st_gid = 0, pad0 = 0, st_rdev = 0, st_size = 4096, st_blksize = 4096, st_blocks = 8,
  st_atim = {tv_sec = 1219366411, tv_nsec = 0}, st_mtim = {tv_sec = 1217493562, tv_nsec = 0}, st_ctim = {tv_sec = 1217493562, tv_nsec = 0}, __unused = {0, 0, 0}}
        i = 0
        fileline = 0
        new_path = 0x0
        retval = 0x0
        kbinput = -1
        meta_key = false
        func_key = false
        old_const_update = false
        abort = false
        prev_dir = 0x0
        ans = 0x13141f0 ""
        old_selected = 18446744073709551615
#1  0x000000000040448a in do_browse_from (inpath=0x13143d0 "") at ../../src/browser.c:436
st = {st_dev = 4340870, st_ino = 140733861747872, st_nlink = 4208192, st_mode = 4317734, st_uid = 0, st_gid = 668360688, pad0 = 32767, st_rdev = 1, st_size = 0,
  st_blksize = 19991392, st_blocks = 140733861747920, st_atim = {tv_sec = 4317941, tv_nsec = 0}, st_mtim = {tv_sec = 1, tv_nsec = 20005840}, st_ctim = {tv_sec = 19991392,
    tv_nsec = 140733861747968}, __unused = {4318014, 4208192, 1}}
path = 0x1315120 "��\217\0374\177"
dir = (DIR *) 0x1315140
#2  0x00000000004084db in do_insertfile (execute=false) at ../../src/files.c:783
tmp = 0x7fff27d65e97 ""
pww_save = 0
i = 20
msg = 0x423c6a "File to insert [from %s] "
ans = 0x1310b60 ""
edittop_save = (filestruct *) 0x13141c0
current_x_save = 0
current_y_save = 0
edittop_inside = false
right_side_up = false
single_line = false
#3  0x000000000040889f in do_insertfile_void () at ../../src/files.c:966
No locals.
#4  0x000000000041288e in do_input (meta_key=0x7fff27d65e97, func_key=0x7fff27d65e96, s_or_t=0x7fff27d65e95, ran_func=0x7fff27d65e94, finished=0x7fff27d65e93, allow_funcs=true)
    at ../../src/nano.c:1521
input = 18
cut_copy = false
s = (const shortcut *) 0x1311f20
have_shortcut = true
t = (const toggle *) 0x0
have_toggle = false
kbinput = (int *) 0x0
kbinput_len = 0
#5  0x0000000000413983 in main (argc=1, argv=0x7fff27d65ff8) at ../../src/nano.c:2306
func_key = false
s_or_t = true
ran_func = true
finished = false
meta_key = false
optchr = -1
startline = 1
startcol = 1
fill_used = false
old_multibuffer = false
long_options = {{name = 0x426aff "help", has_arg = 0, flag = 0x0, val = 104}, {name = 0x426b04 "boldtext", has_arg = 0, flag = 0x0, val = 68}, {
    name = 0x426b0d "multibuffer", has_arg = 0, flag = 0x0, val = 70}, {name = 0x426b19 "ignorercfiles", has_arg = 0, flag = 0x0, val = 73}, {name = 0x426b27 "rebindkeypad",
    has_arg = 0, flag = 0x0, val = 75}, {name = 0x426b34 "nonewlines", has_arg = 0, flag = 0x0, val = 76}, {name = 0x426b3f "morespace", has_arg = 0, flag = 0x0, val = 79}, {
    name = 0x426b49 "quotestr", has_arg = 1, flag = 0x0, val = 81}, {name = 0x426b52 "restricted", has_arg = 0, flag = 0x0, val = 82}, {name = 0x426b5d "tabsize", has_arg = 1,
    flag = 0x0, val = 84}, {name = 0x426b65 "version", has_arg = 0, flag = 0x0, val = 86}, {name = 0x426b6d "syntax", has_arg = 1, flag = 0x0, val = 89}, {
    name = 0x426b74 "const", has_arg = 0, flag = 0x0, val = 99}, {name = 0x426b7a "rebinddelete", has_arg = 0, flag = 0x0, val = 100}, {name = 0x426b87 "nofollow", has_arg = 0,
    flag = 0x0, val = 108}, {name = 0x426b90 "mouse", has_arg = 0, flag = 0x0, val = 109}, {name = 0x426b96 "operatingdir", has_arg = 1, flag = 0x0, val = 111}, {
    name = 0x426ba3 "preserve", has_arg = 0, flag = 0x0, val = 112}, {name = 0x426bac "fill", has_arg = 1, flag = 0x0, val = 114}, {name = 0x426bb1 "speller", has_arg = 1,
    flag = 0x0, val = 115}, {name = 0x426bb9 "tempfile", has_arg = 0, flag = 0x0, val = 116}, {name = 0x426bc2 "view", has_arg = 0, flag = 0x0, val = 118}, {
    name = 0x426bc7 "nowrap", has_arg = 0, flag = 0x0, val = 119}, {name = 0x426bce "nohelp", has_arg = 0, flag = 0x0, val = 120}, {name = 0x426bd5 "suspend", has_arg = 0,
    flag = 0x0, val = 122}, {name = 0x426bdd "smarthome", has_arg = 0, flag = 0x0, val = 65}, {name = 0x426be7 "backup", has_arg = 0, flag = 0x0, val = 66}, {
    name = 0x426bee "backupdir", has_arg = 1, flag = 0x0, val = 67}, {name = 0x426bf8 "tabstospaces", has_arg = 0, flag = 0x0, val = 69}, {name = 0x426c05 "historylog",
    has_arg = 0, flag = 0x0, val = 72}, {name = 0x426c10 "noconvert", has_arg = 0, flag = 0x0, val = 78}, {name = 0x426c1a "smooth", has_arg = 0, flag = 0x0, val = 83}, {
    name = 0x426c21 "quickblank", has_arg = 0, flag = 0x0, val = 85}, {name = 0x426c2c "wordbounds", has_arg = 0, flag = 0x0, val = 87}, {name = 0x426c37 "autoindent",
    has_arg = 0, flag = 0x0, val = 105}, {name = 0x426c42 "cut", has_arg = 0, flag = 0x0, val = 107}, {name = 0x0, has_arg = 0, flag = 0x0, val = 0}}



Jordi Mallach <jordi>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #16403:  .nanorc added by pabs (47B - application/octet-stream)
file #16404:  nanorc added by pabs (7KiB - application/octet-stream)
file #16405:  export added by pabs (3KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Updated the item)
  • -email is unavailable- added by pabs (Updated the item)
  • -email is unavailable- added by astyanax (Posted a comment)
  • -email is unavailable- added by jordi (Submitted the item)
  • -email is unavailable- added by jordi (Original reporter)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-02-23 bens StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2009-10-27 astyanax StatusNeed Info Ready For Test
    2008-08-31 pabs Attached File- Added .nanorc, #16403
        Attached File- Added nanorc, #16404
        Attached File- Added export, #16405
    2008-08-30 astyanax Severity4 - Important 3 - Normal
        StatusNone Need Info
        Assigned toNone astyanax
    2008-08-30 jordi Carbon-Copy- Added paul wise <pabs@debian.org>

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code