[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
floating point exception in mail/headers when msglist is empty...
From: |
Matthew Whitworth |
Subject: |
floating point exception in mail/headers when msglist is empty... |
Date: |
Thu, 27 Jun 2002 16:50:57 -0700 |
The headers command in the 'mail' program generates a floating point
exception when the specified msglist returns no messages:
--
address@hidden:~$ gdb --quiet /usr/local/bin/mail
(gdb) set args --file --nosum
(gdb) run
Starting program: /usr/local/stow/mailutils/bin/mail --file --nosum
[New Thread 1024 (LWP 1666)]
mail (mailutils) 0.0.9d, Copyright (C) 2001 Free Software Foundation, Inc.
mail is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
Send bug reports to <address@hidden>.
? headers :u
Program received signal SIGFPE, Arithmetic exception.
[Switching to Thread 1024 (LWP 1666)]
0x0804c54a in mail_headers (argc=2, argv=0x80909f0) at headers.c:44
44 lines = (lines / num) - 2;
(gdb) bt
#0 0x0804c54a in mail_headers (argc=2, argv=0x80909f0) at
headers.c:44
#1 0x08051615 in util_do_command (c=0x808e9b0 "h :u") at util.c:131
#2 0x0804d7aa in mail_mainloop (input=0x804cbf4 <mail_cmdline>,
closure=0x805a51c, do_history=1) at mail.c:502
#3 0x0804d6a0 in main (argc=2, argv=0x805a828) at mail.c:465
--
As demonstrated, the exception seems to be generated by a
divide-by-zero in headers.c:44. I have patched the file headers.c on
my own system to fix this, but my patch reflects the behavior of the
headers command according to the Single UNIX Specification
(http://www.opengroup.org/onlinepubs/007908799/xcu/mailx.html), in
which headers takes a single message argument rather than a msglist
and displays a screenfull of headers from that point on. (Actually,
mine cheats and uses the first message in the msglist, but whatever.)
--
Index: headers.c
===================================================================
RCS file: /cvsroot/mailutils/mailutils/mail/headers.c,v
retrieving revision 1.11
diff -r1.11 headers.c
28a29,35
> /*
> * NOTE: for the time being, we just find the first message in the
> * msglist and then print the next (lines - 2) headers unless
> * that would go past the end of the mailbox, in which case we
> * start at (total - (lines - 2))...
> */
>
44,46c51,60
< lines = (lines / num) - 2;
< if (lines < 0)
< lines = util_screen_lines ();
---
> if (num == 0)
> {
> fprintf(ofile, "No applicable messages.\n");
> return 1;
> }
>
> if (lines > 2)
> lines -= 2;
>
> cursor = list->msg_part[0];
50,52c64
< low = list->msg_part[0] - (lines / 2);
< if (low < 1)
< low = 1;
---
> low = list->msg_part[0];
53a66
>
--
It appears that you are trying to extend the functionality of the
headers command, but I could not find any documentation to explain
how. I am interested in contributing to the development of the
mailutils/mail program (and/or contributing to the documentation), but
do not want to submit any more patches until I am sure how you intend
to modify the program's behavior. If such documentation exists,
please nudge me in the general direction.
Thank you,
Matthew
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- floating point exception in mail/headers when msglist is empty...,
Matthew Whitworth <=