delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2012/02/27/18:37:30

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
X-Authenticated: #27081556
X-Provags-ID: V01U2FsdGVkX1++bEgqxqO+sM8cHMT2VrskuTcLhYkaj4STk2miCk
D/xNZQuqc198hv
From: Juan Manuel Guerrero <juan DOT guerrero AT gmx DOT de>
To: djgpp-workers AT delorie DOT com
Subject: wrong arument passed to _is_remote_drive in xstat.c
Date: Tue, 28 Feb 2012 00:33:31 +0100
User-Agent: KMail/1.9.10
MIME-Version: 1.0
Message-Id: <201202280033.32584.juan.guerrero@gmx.de>
X-Y-GMX-Trusted: 0
Reply-To: djgpp-workers AT delorie DOT com

There is a bug in _get_cached_blksize().  The drive number passed to
_is_remote_drive() is incremented in the argument.  In _is_remote_drive itself
that drive number is incremented a second time making become the block size
wrong under certain circumstances.  I noticed this while I was trying to port
gdbm 1.9.1.  The testsuite failed depending if the test data base file was
locate on a drive before or after a CDROM drive.  gdbm uses the st_blksize
value to create an initial hash table directory.  If this value does not match
other drive and file specific values the data base file is assumed to be
corrupt and gdbm stops working.

There may be other calls to _is_remote_drive() where the passed argument is
wrong.  The documentation of _is_remote_drive() clearly states that the argument
must be exactly the drive number and not the incremented or decremented one.

Regards,
Juan M. Guerrero


diff -aprNU5 djgpp.orig/src/libc/posix/sys/stat/xstat.c djgpp/src/libc/posix/sys/stat/xstat.c
--- djgpp.orig/src/libc/posix/sys/stat/xstat.c	2001-12-01 20:22:36 +0000
+++ djgpp/src/libc/posix/sys/stat/xstat.c	2012-02-27 23:31:54 +0000
@@ -162,11 +162,11 @@ _get_cached_blksize (const char *path)
       return -1;
     }
 
   if (!cache_blksize[d])
     {
-      if (_is_remote_drive(d + 1))
+      if (_is_remote_drive(d))
 	{
 	  /* Default remote drives to 4K block size, to improve performance.
 	   *
 	   * Also the size returned by statfs() may not be correct. Testing
 	   * against files shared by Samba 2.0.10 on Linux kernel 2.2.19

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019