]> git.kaiwu.me - nginx.git/commitdiff
Secure link: fixed stack buffer overflow.
authorRoman Arutyunyan <arut@nginx.com>
Tue, 22 Aug 2017 18:22:59 +0000 (21:22 +0300)
committerRoman Arutyunyan <arut@nginx.com>
Tue, 22 Aug 2017 18:22:59 +0000 (21:22 +0300)
When secure link checksum has length of 23 or 24 bytes, decoded base64 value
could occupy 17 or 18 bytes which is more than 16 bytes previously allocated
for it on stack.  The buffer overflow does not have any security implications
since only one local variable was corrupted and this variable was not used in
this case.

The fix is to increase buffer size up to 18 bytes.  Useless buffer size
initialization is removed as well.

src/http/modules/ngx_http_secure_link_module.c

index 907ba6ef50c213ed86516f8e8a7cb748b8e9f6a2..536e09a7268a147ee6bdd3891d0f402094c37885 100644 (file)
@@ -107,7 +107,7 @@ ngx_http_secure_link_variable(ngx_http_request_t *r,
     ngx_md5_t                     md5;
     ngx_http_secure_link_ctx_t   *ctx;
     ngx_http_secure_link_conf_t  *conf;
-    u_char                        hash_buf[16], md5_buf[16];
+    u_char                        hash_buf[18], md5_buf[16];
 
     conf = ngx_http_get_module_loc_conf(r, ngx_http_secure_link_module);
 
@@ -154,7 +154,6 @@ ngx_http_secure_link_variable(ngx_http_request_t *r,
         goto not_found;
     }
 
-    hash.len = 16;
     hash.data = hash_buf;
 
     if (ngx_decode_base64url(&hash, &val) != NGX_OK) {