changeset 5965:78271500b8de

A bounds check of %N format on Windows. Thanks to Joe Bialek, Adam Zabrocki and Microsoft Vulnerability Research.
author Igor Sysoev <igor@sysoev.ru>
date Tue, 27 Jan 2015 15:38:15 +0300
parents 0a198a517eaf
children bcdfc39bf44d
files src/core/ngx_string.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/ngx_string.c
+++ b/src/core/ngx_string.c
@@ -429,8 +429,12 @@ ngx_vslprintf(u_char *buf, u_char *last,
             case 'N':
 #if (NGX_WIN32)
                 *buf++ = CR;
+                if (buf < last) {
+                    *buf++ = LF;
+                }
+#else
+                *buf++ = LF;
 #endif
-                *buf++ = LF;
                 fmt++;
 
                 continue;