From nobody@FreeBSD.org  Sun Feb  4 21:28:35 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id D1ABB16A406
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  4 Feb 2007 21:28:35 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [69.147.83.33])
	by mx1.freebsd.org (Postfix) with ESMTP id A99F513C4BA
	for <freebsd-gnats-submit@FreeBSD.org>; Sun,  4 Feb 2007 21:28:35 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id l14LSZlG076647
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 4 Feb 2007 21:28:35 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id l14LSZgs076633;
	Sun, 4 Feb 2007 21:28:35 GMT
	(envelope-from nobody)
Message-Id: <200702042128.l14LSZgs076633@www.freebsd.org>
Date: Sun, 4 Feb 2007 21:28:35 GMT
From: Alex Dupre<ale@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: tip/cu core dump if $HOME is not set
X-Send-Pr-Version: www-3.0

>Number:         108775
>Category:       bin
>Synopsis:       [patch] tip/cu core dump if $HOME is not set
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 04 21:30:15 GMT 2007
>Closed-Date:    Fri Feb 23 19:01:35 GMT 2007
>Last-Modified:  Fri Feb 23 19:10:06 GMT 2007
>Originator:     Alex Dupre
>Release:        FreeBSD 6-STABLE i386
>Organization:
>Environment:
>Description:
The code doesn't check if HOME is not set and does a strlen on a NULL value.
>How-To-Repeat:
# unsetenv HOME
# cu -l /dev/cuad0
Segmentation fault (core dumped)
>Fix:
Untested patch follows:

--- src/usr.bin/tip/tip/value.c  31 Aug 2006 19:19:44 -0000      1.11
+++ src/usr.bin/tip/tip/value.c  4 Feb 2007 21:25:21 -0000
@@ -74,22 +74,25 @@
          * Read the .tiprc file in the HOME directory
          *  for sets
          */
-        if (strlen(value(HOME)) + sizeof("/.tiprc") > sizeof(file)) {
-                (void)fprintf(stderr, "Home directory path too long: %s\n",
-                    value(HOME));
-        } else {
-                snprintf(file, sizeof file, "%s/.tiprc", value(HOME));
-                if ((fp = fopen(file, "r")) != NULL) {
-                        char *tp;
-
-                        while (fgets(file, sizeof(file)-1, fp) != NULL) {
-                                if (vflag)
-                                        printf("set %s", file);
-                                if ((tp = strrchr(file, '\n')))
-                                        *tp = '\0';
-                                vlex(file);
+        cp = value(HOME);
+        if (cp != NULL) {
+                if (strlen(cp) + sizeof("/.tiprc") > sizeof(file)) {
+                        (void)fprintf(stderr, "Home directory path too long: %s\n",
+                            cp);
+                } else {
+                        snprintf(file, sizeof file, "%s/.tiprc", cp);
+                        if ((fp = fopen(file, "r")) != NULL) {
+                                char *tp;
+
+                                while (fgets(file, sizeof(file)-1, fp) != NULL) {
+                                        if (vflag)
+                                                printf("set %s", file);
+                                        if ((tp = strrchr(file, '\n')))
+                                                *tp = '\0';
+                                        vlex(file);
+                                }
+                                fclose(fp);
                         }
-                        fclose(fp);
                 }
         }
         /*

>Release-Note:
>Audit-Trail:

From: Jordan Sissel <psionic@csh.rit.edu>
To: bug-followup@FreeBSD.org, ale@FreeBSD.org
Cc:  
Subject: Re: bin/108775: [patch] tip/cu core dump if $HOME is not set
Date: Fri, 23 Feb 2007 02:58:57 -0500

 Confirmed in -CURRENT@20070221 and in 6.1-RELEASE.
 
 -Jordan

A fix for this was committed today.
State-Changed-From-To: open->closed 
State-Changed-By: jls 
State-Changed-When: Fri Feb 23 18:45:29 UTC 2007 
State-Changed-Why:  
Fix committed for this pr. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=108775 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/108775: commit references a PR
Date: Fri, 23 Feb 2007 18:41:21 +0000 (UTC)

 jls         2007-02-23 18:41:12 UTC
 
   FreeBSD src repository
 
   Modified files:
     usr.bin/tip/tip      value.c 
   Log:
   Make cu/tip handle when $HOME is not set in the environment.
   
   Approved by: philip
   Submitted by: ale
   PR: bin/108775
   
   Revision  Changes    Path
   1.12      +5 -1      src/usr.bin/tip/tip/value.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
