delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/05/26/06:18:55

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.2 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_42
X-Spam-Check-By: sourceware.org
Message-ID: <4A1BC20E.9030903@sysgo.com>
Date: Tue, 26 May 2009 12:18:54 +0200
From: David Engraf <david DOT engraf AT sysgo DOT com>
User-Agent: Thunderbird 2.0.0.21 (X11/20090409)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com, cygwin-patches AT cygwin DOT com
Subject: [PATCH] Re: [1.5] ls -l on /cygdrive/d doesn't work
References: <4A1A94DB DOT 1090807 AT sysgo DOT com> <4A1B9A10 DOT 3000203 AT sysgo DOT com>
In-Reply-To: <4A1B9A10.3000203@sysgo.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--------------080200030508020006000307
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

I have fixed the error in ntea.cc handling the return value of 
NTQueryEaFile. This patch is only needed for the 1.5 release. Maybe this 
error should be considered as critical due to uninitialized stack usage 
of the variable fea when the function returned an error.


2009-05-26 David Engraf <david DOT engraf AT sysgo DOT com>

	* ntea.cc (read_ea): Fix error handling and avoid using
	uninitialized stack.


David Engraf schrieb:
> I think this error is located in the cygwin/ntea.cc read_ea function. 
> NtQueryEaFile fails due to unsupported extended attributes on fat32 and 
> iso9660 and ret is set to -1. After setting ret to -1 the function 
> checks fea->EaValueLength which is in my case 8313 (see log) due to an 
> uninitialized stack and read_ea return 8313. Now the calling function 
> (fhandler_base::fstat_helper) is using the uninitialized data for the 
> timestamp and file size and returns incorrect values.
> This error doesn't happen on the new 1.7 release, but I need a solution 
> for the stable version.
> 
> 
> if (!NT_SUCCESS (status))
>     {
>       ret = -1;
>       debug_printf ("%x = NtQueryEaFile (%s, %s), Win32 error %d",
>                     status, file, attrname, RtlNtStatusToDosError 
> (status));
>     }
>   if (!fea->EaValueLength)
>     ret = 0;
>   else
>     {
>       memcpy (attrbuf, fea->EaName + fea->EaNameLength + 1,
>               fea->EaValueLength);
>       ret = fea->EaValueLength;
>     }
> 
> 
> 
> David Engraf schrieb:
>> Hi,
>>
>> I have encountered a problem while listening the content of a CD. When 
>> I call "ls -l /cygdrive/d" the file size and creation/modification 
>> time is corrupted. This also happens on usb sticks formatted with 
>> fat32. Only ntfs formatted filesystems have the correct listening.
>> Attached is a strace log calling the function fstat on a file located 
>> on the specified filesystem.
>>
>> //ISO9660
>> get_file_attribute: file: d:\README.txt
>> read_ea: 1. chance, C0000010 = NtQueryEaFile (d:\README.txt, 
>> .UNIXATTR), Win32 error 1
>> read_ea: C0000010 = NtQueryEaFile (d:\README.txt, .UNIXATTR), Win32 
>> error 1
>> read_ea: 8313 = read_ea (0, d:\README.txt, .UNIXATTR, 22A9F0, 4)
>> fhandler_base::fstat_helper: 0 = fstat (, 0x22A9E0) st_atime=6B126FF 
>> st_size=-40681930227712, st_mode=0x22A9F061, 
>> st_ino=-4583408731929810241, sizeof=96
>> fstat64: 0 = fstat (3, 0x22A9E0)
>>
>>
>> //FAT32
>> get_file_attribute: file: e:\README.txt
>> read_ea: 1. chance, C000004F = NtQueryEaFile (e:\README.txt, 
>> .UNIXATTR), Win32 error 282
>> read_ea: C000004F = NtQueryEaFile (e:\README.txt, .UNIXATTR), Win32 
>> error 282
>> read_ea: 8313 = read_ea (0, e:\README.txt, .UNIXATTR, 22A9F0, 4)
>> fhandler_base::fstat_helper: 0 = fstat (, 0x22A9E0) st_atime=6D7072 
>> st_size=3328772759537140781, st_mode=0x22A9F061, 
>> st_ino=-3532118121688219773, sizeof=96
>> fstat64: 0 = fstat (3, 0x22A9E0)
>>
>>
>> //NTFS
>> get_file_attribute: file: c:\README.txt
>> read_ea: 0 = read_ea (6BC, c:\README.txt, .UNIXATTR, 22A410, 4)
>> fhandler_base::fstat_helper: 0 = fstat (, 0x22A400) st_atime=4A1A7CA3 
>> st_size=3088, st_mode=0x8124, st_ino=3096224743855743, sizeof=96
>> fstat64: 0 = fstat (6, 0x22A400)
>>
>>
>> Thank you
>>
> 

-- 
David Engraf
Product Engineer

SYSGO AG
Office Mainz
Am Pfaffenstein 14 / D-55270 Klein-Winternheim / Germany

Handelsregister: HRB Mainz 90 HRB 8066
Vorstand: Michael Tiedemann
Aufsichtsratsvorsitzender: Knut Degen
USt(VAT)-Id-Nr.: DE 149062328

--------------080200030508020006000307
Content-Type: text/x-diff;
 name="fix_ntea.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="fix_ntea.patch"

--- cygwin-1.5.25-15/winsup/cygwin/ntea.cc_orig	2008-04-16 14:57:15.000000000 +0200
+++ cygwin-1.5.25-15/winsup/cygwin/ntea.cc	2009-05-26 12:05:39.000000000 +0200
@@ -85,13 +85,16 @@ read_ea (HANDLE hdl, const char *file, c
       debug_printf ("%x = NtQueryEaFile (%s, %s), Win32 error %d",
 		    status, file, attrname, RtlNtStatusToDosError (status));
     }
-  if (!fea->EaValueLength)
-    ret = 0;
   else
     {
-      memcpy (attrbuf, fea->EaName + fea->EaNameLength + 1,
-	      fea->EaValueLength);
-      ret = fea->EaValueLength;
+      if (!fea->EaValueLength)
+        ret = 0;
+      else
+        {
+          memcpy (attrbuf, fea->EaName + fea->EaNameLength + 1,
+	          fea->EaValueLength);
+          ret = fea->EaValueLength;
+        }
     }
 
 out:


--------------080200030508020006000307
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
--------------080200030508020006000307--

- Raw text -


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