regedit: Avoid registry export error when string data is zero sized
Bruno Jesus
00cpxxx at gmail.com
Fri Feb 14 14:52:57 CST 2014
If a NULL is concatenated into the output string no more data will be
appended resulting in errors.
Fixes http://bugs.winehq.org/show_bug.cgi?id=21945
-------------- next part --------------
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index 18b6e98..ec43218 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -1180,10 +1180,12 @@ static void export_hkey(FILE *file, HKEY key,
lstrcpyW(*line_buf + line_len, start);
line_len += len;
- /* At this point we know wstr is '\0'-terminated
- * so we can subtract 1 from the size
+ /* At this point we know wstr is '\0'-terminated so we can subtract 1 from the size
+ * We only need to concat strings with len > 0, otherwise the extra NULL added in
+ * export string will result in corrupted output
*/
- REGPROC_export_string(line_buf, line_buf_size, &line_len, wstr, val_size1 / sizeof(WCHAR) - 1);
+ if (lstrlenW(wstr))
+ REGPROC_export_string(line_buf, line_buf_size, &line_len, wstr, val_size1 / sizeof(WCHAR) - 1);
REGPROC_resize_char_buffer(line_buf, line_buf_size, line_len + lstrlenW(end));
lstrcpyW(*line_buf + line_len, end);
More information about the wine-patches
mailing list