X-Recipient: archive-cygwin@delorie.com X-SWARE-Spam-Status: No, hits=3.2 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KAM_THEBAT X-Spam-Check-By: sourceware.org Date: Wed, 26 May 2010 17:42:27 +0400 From: Andrey Repin Reply-To: Andrey Repin Message-ID: <1254830174.20100526174227@mtu-net.ru> To: Corinna Vinschen Subject: Re: Reading /proc/registry/... returns extra char In-Reply-To: <20100526114733.GG10652@calimero.vinschen.de> References: <20100513181249.GE13784@cupro.opengvs.com> <2BF01EB27B56CC478AD6E5A0A28931F2F01D44@A1DAL1SWPES19MB.ams.acs-inc.net> <20100526114733.GG10652@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Delivered-To: mailing list cygwin@cygwin.com Greetings, Corinna Vinschen! >> > $ cat >a.dat >> > /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Syst >> > emBootDevice > This trailing NUL character was always there, already with Cygwin 1.5. > It's part of the file content. If strings are stored with a trailing > NUL in a file, you don't want Cygwin to remove it for you, right? Wrong. The training NULL is a string value terminator for REG_SZ variables, also a string separator for REG_MULTI_SZ ones. (Which ends with a spare NULL) It must not be exposed to the user. Seriously, when you are working with NULL-terminated strings, do you print the NULL to the user? Or, more specifically, can you ever reach it using string functions in first place? No, only using direct memory access you can discover the NULL at the end of a string. BTW, get it as a bugreport - reading REG_MULTI_SZ from /proc/registry returns only first string. REGEDIT4 [HKEY_CURRENT_USER\Software\ACB] "test"=hex(7):61,73,64,61,73,64,00,61,61,73,61,64,73,00,00 $ cat /proc/registry/HKEY_CURRENT_USER/Software/ACB/test asdasd -- WBR, Andrey Repin (anrdaemon@freemail.ru) 26.05.2010, <17:31> Sorry for my terrible english... -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple