Christian Franke | 1 Dec 2008 20:23
Picon
Favicon

[Patch] Encode invalid chars in /proc/registry entries (merge from 1.5)

This is a 1.5->1.7 merge of my patch from 
http://sourceware.org/ml/cygwin-patches/2007-q4/msg00017.html

Christian

2008-12-01  Christian Franke  <franke <at> computer.org>

	* fhandler_registry.cc (must_encode): New function.
	(encode_regname): Ditto.
	(decode_regname): Ditto.
	(fhandler_registry::exists): Encode name before path compare.
	(fhandler_registry::fstat): Pass decoded name to win32 registry call.
	(fhandler_registry::readdir): Return encoded name to user.
	(fhandler_registry::open): Store decoded name into value_name.
	(open_key): Pass decoded name to win32 registry call

Corinna Vinschen | 2 Dec 2008 12:46
Favicon

Re: [Patch] Encode invalid chars in /proc/registry entries (merge from 1.5)

On Dec  1 20:23, Christian Franke wrote:
> This is a 1.5->1.7 merge of my patch from 
> http://sourceware.org/ml/cygwin-patches/2007-q4/msg00017.html
>
> Christian
>
>
> 2008-12-01  Christian Franke  <franke <at> computer.org>
>
> 	* fhandler_registry.cc (must_encode): New function.
> 	(encode_regname): Ditto.
> 	(decode_regname): Ditto.
> 	(fhandler_registry::exists): Encode name before path compare.
> 	(fhandler_registry::fstat): Pass decoded name to win32 registry call.
> 	(fhandler_registry::readdir): Return encoded name to user.
> 	(fhandler_registry::open): Store decoded name into value_name.
> 	(open_key): Pass decoded name to win32 registry call

Patch applied.

Thanks,
Corinna

--

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

Pierre A. Humblet | 3 Dec 2008 17:25
Picon

[Patch] Minires update

This patch syncs the built-in minires with the latest packaged version.
Also attaching the files to guarantee format preservation.

Pierre

2008-12-03  Pierre A. Humblet  <Pierre.Humblet <at> ieee.org>

        * libc/minires.c (open_sock): Set non blocking and close on exec.
        (res_ninit): Set id pseudo-randomly.
        (res_nsend): Do not set close on exec. Initialize server from id.
        Flush socket. Tighten rules for answer acceptance.
        (res_nmkquery): Update id using current data.

Index: minires.c
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/libc/minires.c,v
retrieving revision 1.4
diff -u -p -r1.4 minires.c
--- minires.c 1 Apr 2008 10:22:33 -0000 1.4
+++ minires.c 3 Dec 2008 02:57:26 -0000
 <at>  <at>  -1,6 +1,6  <at>  <at> 
 /* minires.c.  Stub synchronous resolver for Cygwin.

-   Copyright 2006 Red Hat, Inc.
+   Copyright 2008 Red Hat, Inc.

    Written by Pierre A. Humblet <Pierre.Humblet <at> ieee.org>

 <at>  <at>  -225,6 +225,17  <at>  <at>  static int open_sock(struct sockaddr_in 
     DPRINTF(debug, "socket(UDP): %s\n", strerror(errno));
(Continue reading)

Corinna Vinschen | 3 Dec 2008 17:40
Favicon

Re: [Patch] Minires update

On Dec  3 11:25, Pierre A. Humblet wrote:
> This patch syncs the built-in minires with the latest packaged version.
> Also attaching the files to guarantee format preservation.
> 
> Pierre
> 
> 2008-12-03  Pierre A. Humblet  <Pierre.Humblet <at> ieee.org>
> 
>         * libc/minires.c (open_sock): Set non blocking and close on exec.
>         (res_ninit): Set id pseudo-randomly.
>         (res_nsend): Do not set close on exec. Initialize server from id.
>         Flush socket. Tighten rules for answer acceptance.
>         (res_nmkquery): Update id using current data.

Applied with a very minor change:

> Index: minires.c
> ===================================================================
> RCS file: /cvs/src/src/winsup/cygwin/libc/minires.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 minires.c
> --- minires.c 1 Apr 2008 10:22:33 -0000 1.4
> +++ minires.c 3 Dec 2008 02:57:26 -0000
>  <at>  <at>  -1,6 +1,6  <at>  <at> 
>  /* minires.c.  Stub synchronous resolver for Cygwin.
>  
> -   Copyright 2006 Red Hat, Inc.
> +   Copyright 2008 Red Hat, Inc.

The Copyright should keep the old dates, like this:
(Continue reading)

Christian Franke | 4 Dec 2008 21:49
Picon
Favicon

[Patch] Avoid duplicate names in /proc/registry (which may crash find)

Here is a simple approach to handle the duplicate key/value name problem 
in /proc/registry. A value is skipped if key with same name exists. 
Number of actual key existence checks are reduced by a simple hash table.

The patch also adds dirent.d_type support, find does no longer crash.

Christian

2008-12-04  Christian Franke  <franke <at> computer.org>

	* fhandler_registry.cc (__DIR_hash): New class.
	(d_hash): New macro.
	(key_exists): New function.
	(fhandler_registry::readdir): Allocate __DIR_hash.
	Record key names in hash table. Skip value if key
	with same name exists. Fix error handling of
	encode_regname (). Set dirent.d_type.
	(fhandler_registry::closedir): Delete __DIR_hash.

Corinna Vinschen | 5 Dec 2008 10:57
Favicon

Re: [Patch] Avoid duplicate names in /proc/registry (which may crash find)

On Dec  4 21:49, Christian Franke wrote:
> Here is a simple approach to handle the duplicate key/value name problem in 
> /proc/registry. A value is skipped if key with same name exists. Number of 
> actual key existence checks are reduced by a simple hash table.
>
> The patch also adds dirent.d_type support, find does no longer crash.
>
> Christian
>
>
> 2008-12-04  Christian Franke  <franke <at> computer.org>
>
> 	* fhandler_registry.cc (__DIR_hash): New class.
> 	(d_hash): New macro.
> 	(key_exists): New function.
> 	(fhandler_registry::readdir): Allocate __DIR_hash.
> 	Record key names in hash table. Skip value if key
> 	with same name exists. Fix error handling of
> 	encode_regname (). Set dirent.d_type.
> 	(fhandler_registry::closedir): Delete __DIR_hash.

That looks like a quite neat idea to rectify this problem but, now that
I think of it I'm wondering if this isn't a good starting point for
a better solution as you proposed on the Cygwin list.

So let's assume there's a key and a value with the same name. 

The old implementation just ignored the problem.  Trying to access the
value failed because the value was simply shadowed by the key.  `cat
foo' returned "is a directory" or something.
(Continue reading)

Christian Franke | 5 Dec 2008 23:23
Picon
Favicon

Re: [Patch] Avoid duplicate names in /proc/registry (which may crash find)

Corinna Vinschen wrote:
> On Dec  4 21:49, Christian Franke wrote:
>   
>> Here is a simple approach to handle the duplicate key/value name problem in 
>> /proc/registry. A value is skipped if key with same name exists. Number of 
>> actual key existence checks are reduced by a simple hash table.
>>
>> ...
>>     
>
> That looks like a quite neat idea to rectify this problem but, now that
> I think of it I'm wondering if this isn't a good starting point for
> a better solution as you proposed on the Cygwin list.
>
>   

Yes, it is ... see below.

> So let's assume there's a key and a value with the same name. 
>
> The old implementation just ignored the problem.  Trying to access the
> value failed because the value was simply shadowed by the key.  `cat
> foo' returned "is a directory" or something.
>
> The now proposed solution hides the value instead.  There just isn't a
> value of that name anymore.  In the end, the result is the same.
> Accessing the value still doesn't work.
>
>   

(Continue reading)

Corinna Vinschen | 7 Dec 2008 18:18
Favicon

Re: [Patch] Avoid duplicate names in /proc/registry (which may crash find)

Hi Christian,

On Dec  5 23:23, Christian Franke wrote:
> Corinna Vinschen wrote:
>> Maybe ".val" is already a good suffix?
>
> I would prefer "%val" to avoid any extra encoding for names using ".val". 
> The "%" is already used as an escape char, so "%val" in a name would appear 
> as "%25val"

Very good idea!

> With the attached patch, a duplicate name "foo" is handled as follows:
>
> - readdir() returns the key as "foo" and the value as "foo%val".
> - If the name is "foo%val", stat() and open() consider only the value 
> "foo".
>
> This keeps the names 'as is' if possible and allows access to the (very 
> few) entries with duplicate names. The "%val" is at least somewhat 
> self-explanatory.

Cool.  Can you please send a ChangeLog entry as well?

Thanks,
Corinna

--

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
(Continue reading)

Christian Franke | 7 Dec 2008 20:03
Picon
Favicon

Re: [Patch] Avoid duplicate names in /proc/registry (which may crash find)

Hi Corinna,

Corinna Vinschen wrote:
> ...
>> With the attached patch, a duplicate name "foo" is handled as follows:
>>
>> - readdir() returns the key as "foo" and the value as "foo%val".
>> - If the name is "foo%val", stat() and open() consider only the value 
>> "foo".
>>
>> This keeps the names 'as is' if possible and allows access to the (very 
>> few) entries with duplicate names. The "%val" is at least somewhat 
>> self-explanatory.
>>     
>
> Cool.  Can you please send a ChangeLog entry as well?
>
>   

Of course:

2008-12-07  Christian Franke  <franke <at> computer.org>

	* fhandler_registry.cc (encode_regname): Add Parameter add_val.
	Append "%val" if add_val is set.
	(decode_regname): Remove trailing "%val". Change returncode
	accordingly.
	(__DIR_hash): New class.
	(d_hash): New macro.
	(key_exists): New function.
(Continue reading)

Corinna Vinschen | 8 Dec 2008 12:48
Favicon

Re: [Patch] Avoid duplicate names in /proc/registry (which may crash find)

On Dec  7 20:03, Christian Franke wrote:
> Corinna Vinschen wrote:
>> ...
>>> With the attached patch, a duplicate name "foo" is handled as follows:
>>>
>>> - readdir() returns the key as "foo" and the value as "foo%val".
>>> - If the name is "foo%val", stat() and open() consider only the value 
>>> "foo".
>>[...]
>> Cool.  Can you please send a ChangeLog entry as well?
>
> Of course:

Thanks!  Patch applied.

Corinna

--

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat


Gmane