delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/12/01/15:17:33

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Message-ID: <4934461E.5040708@t-online.de>
Date: Mon, 01 Dec 2008 21:16:30 +0100
From: Christian Franke <Christian DOT Franke AT t-online DOT de>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 SeaMonkey/1.1.11
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Avoid duplicate names in /proc/registry (which may crash find) ?
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

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

When dirent.d_type support is added to /proc/registry (see attachment), 
find 4.4.0-3 crashes on keys with duplicate names.

Testcases:

$ find-with-d_type \
/proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/ALG/ISV

$ find-with-d_type \
/proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Services/Eventlog/Security

These keys contain a key and a value with the same name and readdir() 
returns both (with different d_type).

Possible fix to avoid identical names:


1. Put keys and values in different namespaces, e.g.

/proc/registry/path/name.key
/proc/registry/path/name.val

Drawback: Breaks backward compatibility.


or:

2. In readdir(), record the key names in some set<> or hash-table. If 
(and only if) a duplicate name is detected, return a modified name for 
the value:

/proc/registry/path/name
/proc/registry/path/name%76  ('v')

Drawback: Slows down readdir, introduces alias name for value.


Christian


--------------030900090709040606020800
Content-Type: text/x-patch;
 name="cygwin-1.7-registry-dirent-d_type.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="cygwin-1.7-registry-dirent-d_type.patch"

diff --git a/winsup/cygwin/fhandler_registry.cc b/winsup/cygwin/fhandler_registry.cc
index ce4335f..1690427 100644
--- a/winsup/cygwin/fhandler_registry.cc
+++ b/winsup/cygwin/fhandler_registry.cc
@@ -432,7 +432,13 @@ retry:
 
   dir->__d_position++;
   if (dir->__d_position & REG_ENUM_VALUES_MASK)
-    dir->__d_position += 0x10000;
+    {
+      dir->__d_position += 0x10000;
+      de->d_type = DT_REG;
+    }
+  else
+    de->d_type = DT_DIR;
+
   res = 0;
 out:
   syscall_printf ("%d = readdir (%p, %p)", res, dir, de);


--------------030900090709040606020800
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/
--------------030900090709040606020800--

- Raw text -


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