Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Jul 1999 03:09:05 -0700
From:      aaron@mutex.org
To:        FreeBSD-gnats-submit@freebsd.org
Cc:        aaron@mutex.org
Subject:   ports/12761: sysutils/stat fails to properly terminate buffer and can print garbage
Message-ID:  <199907221009.DAA12862@sigma.veritas.com>

next in thread | raw e-mail | index | archive | help

>Number:         12761
>Category:       ports
>Synopsis:       sysutils/stat doesn't terminate buffer and can print garbage
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 22 03:10:02 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Aaron Smith
>Release:        FreeBSD 3.2-RELEASE i386
>Organization:
Mutant X
>Environment:

stat-1.3            Print inode contents

>Description:

the FmtInode function in stat.fmt.c does not properly null terminate
its result in the supplied buffer. this can result in garbage characters
and errors.

>How-To-Repeat:

either put a memset in stat_it or change malloc.conf so that the buffer is
explicitly nonzero, and try running stat against a few different files. you
should see a garbage char on the final (supposed to be blank) line.

>Fix:

the following patch makes FmtInode terminate its result.

--- stat.fmt.c.orig	Sun Feb 16 05:12:33 1997
+++ stat.fmt.c	Wed Jul 14 17:20:36 1999
@@ -500,6 +500,7 @@
 			}
 		}
 	}
+	*bufp++ = '\0';
 }
 /*
 **  USAGE -- Display a reminder


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199907221009.DAA12862>