public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: peturr02@ru.is
To: gcc-gnats@gcc.gnu.org
Subject: libstdc++/9507: filebuf::open handles ios_base::ate incorrectly
Date: Thu, 30 Jan 2003 14:46:00 -0000	[thread overview]
Message-ID: <20030130144413.12219.qmail@sources.redhat.com> (raw)


>Number:         9507
>Category:       libstdc++
>Synopsis:       filebuf::open handles ios_base::ate incorrectly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 30 14:46:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     peturr02@ru.is
>Release:        gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
When the flag ios_base::ate is passed to basic_filebuf::open, the filebuf tries to seek to the end of the file (as expected). If this seek fails, the file is closed before open returns (also as expected). However, the return value still indicates that open was successful, even though is_open is false after the call to open.
>How-To-Repeat:
See attachment.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="openseekbug.cc"
Content-Disposition: inline; filename="openseekbug.cc"

#include <fstream>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>

#undef NDEBUG
#include <cassert>

int main()
{
	using namespace std;

	signal(SIGPIPE, SIG_IGN);

	unlink("xxx");
	mkfifo("xxx", S_IRWXU);

	if (!fork())
	{
		filebuf fbuf;
		fbuf.open("xxx", ios_base::in);
		fbuf.sgetc();
		fbuf.close();

		exit(0);
	}

	filebuf fbuf;
	filebuf* r = fbuf.open("xxx", ios_base::out | ios_base::ate);
	assert(!fbuf.is_open());
	assert(r == NULL);

	unlink("xxx");
	return 0;
}


             reply	other threads:[~2003-01-30 14:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-30 14:46 peturr02 [this message]
2003-02-01 23:17 paolo
2003-02-04 18:18 paolo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030130144413.12219.qmail@sources.redhat.com \
    --to=peturr02@ru.is \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).