NetBSD Problem Report #155

From gnats  Sat Mar  5 13:26:00 1994
Received: from skarven.dsl.unit.no (skarven.dsl.unit.no [129.241.36.65]) by sun-lamp.cs.berkeley.edu (8.6.5/8.6.5) with ESMTP id NAA00642 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Sat, 5 Mar 1994 13:25:58 -0800
Message-Id: <199403052130.WAA01446@skarven.dsl.unit.no>
Date: Sat, 5 Mar 1994 22:30:11 +0100
From: Arne H}strek Juul <arnej@dsl.unit.no>
Reply-To: arnej@dsl.unit.no
To: gnats-bugs@sun-lamp.cs.berkeley.edu
Subject: mail leaves garbage NULs in files
X-Send-Pr-Version: 3.2

>Number:         155
>Category:       bin
>Synopsis:       Mail appended to mbox is preceded by NULs.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    gnats-admin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 05 13:35:01 +0000 1994
>Closed-Date:    Sun Mar 06 03:05:29 +0000 1994
>Last-Modified:  Thu Jan 02 18:11:50 +0000 2014
>Originator:     Arne Juul
>Release:        
>Organization:
University of Trondheim, Norway
>Environment:
	NetBSD-current as of today
System: NetBSD skarven.dsl.unit.no 0.9a SKARVEN#1 i386


>Description:
	Messages read from mail are saved in mbox preceded by NULs.
	This is because of bogus use of ftruncate, effectively
	extending the file to the place where the messages should
	have ended, *then* appending the messages. May have been
	hidden by non-extending ftruncate or erronous append mode
	before.
>How-To-Repeat:
	With no special set-up (?), read mail and quit.
>Fix:
	Apply patch below, flushing stream before truncating.

*** def.h.orig	Fri Dec 17 08:13:38 1993
--- def.h	Sat Mar  5 22:13:19 1994
***************
*** 267,273 ****
   * useful just before closing an old file that was opened
   * for read/write.
   */
! #define trunc(stream)	ftruncate(fileno(stream), (long) ftell(stream))

  /*
   * Forward declarations of routine types to keep lint and cc happy.
--- 267,276 ----
   * useful just before closing an old file that was opened
   * for read/write.
   */
! #define trunc(stream)	do { \
! 		fflush(stream); \
! 		ftruncate(fileno(stream), (long) ftell(stream)) ; \
! 	} while (0)

  /*
   * Forward declarations of routine types to keep lint and cc happy.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: cgd 
State-Changed-When: Sat Mar 5 19:05:29 PST 1994 
State-Changed-Why:  
applied. 

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.