From owner-freebsd-standards@FreeBSD.ORG Thu Jul 22 01:42:42 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B602816A4CE for ; Thu, 22 Jul 2004 01:42:42 +0000 (GMT) Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id A9A6643D2F for ; Thu, 22 Jul 2004 01:42:42 +0000 (GMT) (envelope-from mjoyner@vbservices.net) Received: from mike.vbservices.net (c-66-177-116-188.se.client2.attbi.com[66.177.116.188]) by comcast.net (rwcrmhc12) with ESMTP id <2004072201424101400393pde>; Thu, 22 Jul 2004 01:42:41 +0000 Received: from vbservices.net (localhost [IPv6:::1]) by mike.vbservices.net (8.12.11/8.12.11) with ESMTP id i6LLhtnM097067; Wed, 21 Jul 2004 21:43:55 GMT (envelope-from mjoyner@vbservices.net) Message-ID: <40FEE39B.6070807@vbservices.net> Date: Wed, 21 Jul 2004 21:43:55 +0000 From: Michael Joyner User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.6) Gecko/20040519 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Steven Narmontas References: <003b01c468cc$914ac4f0$0810050a@narmontas> In-Reply-To: <003b01c468cc$914ac4f0$0810050a@narmontas> X-Enigmail-Version: 0.84.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-standards@freebsd.org Subject: Re: [Manhat]"Bug" detected... in fseek X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jul 2004 01:42:43 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The fseek command is *always* succeeding, on the seeks to BEFORE THE BEGINNING OF THE FILE! (if I remember my random access correctly, this is expected behavior, at least in the positive direction, not sure if it supposed to work that way in the negative direction though... maybe be a "standards" compliancy bug of some sort) as a result the following fread command is trying to read non-existant data, and errno is set to 'file to big', (gotta love those error messages... I am thinking it is taking the negative value for the raw offset and treating it as an unsigned long internally, yielding a file size and location that is bigger than 1 Terabyte) the modified version below seems to work fine on FreeBSD w/o giving a segfault or anything and should be functionally equivelant to the original, except for the fread error check. :) void record_recent_logins (CONFIG_STRUCT *conf, USER_LOG_NODE *head) { ~ USER_LOG_NODE *person_ptr; ~ char logpath[MAX_PATH + 1]; ~ FILE *fp; ~ int i; ~ for (person_ptr = head; person_ptr; person_ptr = person_ptr->next) ~ { ~ for (i = 0; i < MAX_LOGINS; i++) ~ person_ptr->login_time[i] = (time_t) 0; ~ snprintf (logpath, MAX_PATH + 1, "%speople/%s/%s", ~ conf->course_path, person_ptr->user.username, ACCESS_LOG_FNAME); ~ fp = fopen (logpath, "r"); ~ if (fp) ~ { ~ for (i = 0; i < MAX_LOGINS; i++) ~ { ~ if (!fseek(fp, -((i + 1) * sizeof (time_t)), SEEK_END)) ~ fread (&(person_ptr->login_time[i]), sizeof (time_t), 1, fp); ~ } ~ fclose (fp); ~ } ~ } } Steven Narmontas wrote: | Michael, | | I'm very busy delivering Manhattan workshops all this week. | | I'll try to look into this issue early next week... | | Thanks, | Steve Narmontas | | Error reading file | | Platform: FreeBSD 4-STABLE | Manhattan: Version 2.4 | | ideas? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFA/uObOElk0ppmOXwRAspqAJ91zJFrCsv6pdP9lTfldNQJsIK0dwCfVyon 3/ppajB8khPNE4tSmp0CO8c= =fYa1 -----END PGP SIGNATURE-----