From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10112 invoked by alias); 7 Mar 2003 11:26:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 10071 invoked by uid 71); 7 Mar 2003 11:26:00 -0000 Resent-Date: 7 Mar 2003 11:26:00 -0000 Resent-Message-ID: <20030307112600.10069.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, peturr02@ru.is Received: (qmail 9330 invoked by uid 48); 7 Mar 2003 11:22:39 -0000 Message-Id: <20030307112239.9329.qmail@sources.redhat.com> Date: Fri, 07 Mar 2003 11:26:00 -0000 From: peturr02@ru.is Reply-To: peturr02@ru.is To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/9988: filebuf::overflow writes EOF to file X-SW-Source: 2003-03/txt/msg00346.txt.bz2 List-Id: >Number: 9988 >Category: libstdc++ >Synopsis: filebuf::overflow writes EOF to file >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Fri Mar 07 11:26:00 UTC 2003 >Closed-Date: >Last-Modified: >Originator: peturr02@ru.is >Release: gcc-3.2.1 >Organization: >Environment: Red Hat Linux 8.0 >Description: If the parameter passed to filebuf::overflow equals traits_type::eof() it is written to the file. >How-To-Repeat: See attachment. >Fix: Check for EOF before writing character. >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="overflowbug.cc" Content-Disposition: inline; filename="overflowbug.cc" #include #undef NDEBUG #include class Buf : public std::filebuf { public: int_type pub_overflow(int_type c = traits_type::eof()) { return std::filebuf::overflow(c); } }; int main() { using namespace std; Buf fb; fb.open("tmp", ios_base::out); fb.sputc('a'); fb.pub_overflow('b'); fb.pub_overflow(); fb.sputc('c'); fb.close(); filebuf fbin; fbin.open("tmp", ios_base::in); int c; c = fbin.sbumpc(); assert(c == 'a'); c = fbin.sbumpc(); assert(c == 'b'); c = fbin.sbumpc(); assert(c == 'c'); c = fbin.sbumpc(); assert(c == filebuf::traits_type::eof()); fbin.close(); return 0; }