Unix Technical Forum

Two smaller overflows in mail(1)

This is a discussion on Two smaller overflows in mail(1) within the mailing.openbsd.tech forums, part of the OpenBSD category; --> Hello, I have found some smaller overflow issues in /usr/bin/mail (both in OpenBSD 3.7 and in the latest CVS ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2008, 07:55 AM
Ulf Harnhammar
 
Posts: n/a
Default Two smaller overflows in mail(1)

Hello,

I have found some smaller overflow issues in /usr/bin/mail (both in
OpenBSD 3.7 and in the latest CVS version). They don't seem to have any
security impact.


a) off-by-one bug


There is an off-by-one bug in readtty() in tty.c. It writes '\0'
just outside a character array when the user input is long enough.
The following patch fixes this glitch:


--- usr.bin/mail/tty.c.old 2003-06-03 04:56:11.000000000 +0200
+++ usr.bin/mail/tty.c 2005-06-19 01:13:49.577213600 +0200
@@ -230,7 +230,7 @@ readtty(char *pr, char *src)
(void)sigaction(SIGTTIN, &act, NULL);
(void)sigprocmask(SIG_UNBLOCK, &intset, &oset);
clearerr(stdin);
- while (cp2 < canonb + BUFSIZ) {
+ while (cp2 < canonb + BUFSIZ - 1) {
c = getc(stdin);
switch (ttysignal) {
case SIGINT:


b) buffer overflow if BUFSIZ > 1024


If BUFSIZ is larger than 1024 (the value of STRINGLEN) and scan() in
list.c is called with a long string containing many digits, there is
a buffer overflow. One system that gets hit by this bug is
Debian GNU/Linux (see bug #313306 [1]). Relying on such outside factors
as the value of BUFSIZ is a bug in the code, even if it might not have
any effect on a stock OpenBSD system. Here is a patch for this little
programming mistake that causes crashes on certain systems:


--- usr.bin/mail/list.c.old 2004-11-23 10:10:35.000000000 +0100
+++ usr.bin/mail/list.c 2005-06-19 01:16:03.498854416 +0200
@@ -543,7 +543,8 @@ scan(char **sp)
lexnumber = 0;
while (isdigit(c)) {
lexnumber = lexnumber*10 + c - '0';
- *cp2++ = c;
+ if (cp2 - lexstring < STRINGLEN-1)
+ *cp2++ = c;
c = *cp++;
}
*cp2 = '\0';


[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=313306


// Ulf Harnhammar

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:09 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com