Alexander Nicolaysen Sørnes : regedit: Null-terminate buffer in Unicode file import.

Alexandre Julliard julliard at winehq.org
Fri Jul 11 08:44:20 CDT 2008


Module: wine
Branch: master
Commit: 2a9713a6cb8cc41db5a7001201ad4793b82d93cf
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2a9713a6cb8cc41db5a7001201ad4793b82d93cf

Author: Alexander Nicolaysen Sørnes <alex at thehandofagony.com>
Date:   Fri Jul 11 13:21:17 2008 +0200

regedit: Null-terminate buffer in Unicode file import.

---

 programs/regedit/regproc.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index 98fd8b1..a716f3d 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -737,11 +737,12 @@ void processRegLinesW(FILE *in)
         }
 
         /* Get as much as possible into the buffer, terminated either by
-        * eof, error, eol or getting the maximum amount.  Abort on error.
+        * eof, error or getting the maximum amount.  Abort on error.
         */
         size_to_get = (size_remaining > INT_MAX ? INT_MAX : size_remaining);
 
-        check = fread(s, sizeof(WCHAR), size_to_get, in);
+        check = fread(s, sizeof(WCHAR), size_to_get - 1, in);
+        s[check] = 0;
 
         if (check == 0) {
             if (ferror(in)) {
@@ -762,6 +763,9 @@ void processRegLinesW(FILE *in)
         {
             s_eol = strchrW(s, '\n');
 
+            if(!s_eol)
+                break;
+
             /* If it is a comment line then discard it and go around again */
             if (*s == '#') {
                 s = s_eol + 1;




More information about the wine-cvs mailing list