From 1e0a77622b8b3cfe1c98624feb23f3ef67e915b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Sun, 21 Sep 2008 23:20:42 +0200 Subject: [PATCH] regedit: Fix char escaping for registry export. --- programs/regedit/regproc.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c index 3ee7370dbbe..ce26319e278 100644 --- a/programs/regedit/regproc.c +++ b/programs/regedit/regproc.c @@ -885,7 +885,7 @@ static void REGPROC_export_string(WCHAR **line_buf, DWORD *line_buf_size, DWORD DWORD i; DWORD extra = 0; - REGPROC_resize_char_buffer(line_buf, line_buf_size, len + 10); + REGPROC_resize_char_buffer(line_buf, line_buf_size, len + *line_size + 10); /* escaping characters */ for (i = 0; i < len; i++) { @@ -895,37 +895,36 @@ static void REGPROC_export_string(WCHAR **line_buf, DWORD *line_buf_size, DWORD { const WCHAR escape[] = {'\\','\\'}; + REGPROC_resize_char_buffer(line_buf, line_buf_size, len + *line_size + extra + 1); + memcpy(*line_buf + *line_size + i + extra - 1, escape, 2 * sizeof(WCHAR)); extra++; - REGPROC_resize_char_buffer(line_buf, line_buf_size, len + extra); - memcpy(*line_buf + *line_size - 1, escape, 2 * sizeof(WCHAR)); break; } - case '\"': + case '"': { const WCHAR escape[] = {'\\','"'}; + REGPROC_resize_char_buffer(line_buf, line_buf_size, len + *line_size + extra + 1); + memcpy(*line_buf + *line_size + i + extra - 1, escape, 2 * sizeof(WCHAR)); extra++; - REGPROC_resize_char_buffer(line_buf, line_buf_size, len + extra); - memcpy(*line_buf + *line_size - 1, escape, 2 * sizeof(WCHAR)); break; } case '\n': { - const WCHAR escape[] = {'\\','\n'}; + const WCHAR escape[] = {'\\','n'}; + REGPROC_resize_char_buffer(line_buf, line_buf_size, len + *line_size + extra + 1); + memcpy(*line_buf + *line_size + i + extra - 1, escape, 2 * sizeof(WCHAR)); extra++; - REGPROC_resize_char_buffer(line_buf, line_buf_size, len + extra); - memcpy(*line_buf + *line_size - 1, escape, 2 * sizeof(WCHAR)); break; } default: - memcpy(*line_buf + *line_size - 1, &c, sizeof(WCHAR)); + memcpy(*line_buf + *line_size + i + extra - 1, &c, sizeof(WCHAR)); break; } - *line_size += 1; } + *line_size += len + extra; *(*line_buf + *line_size - 1) = 0; - *line_size += extra; } /******************************************************************************