Skip to content

Commit 4b8f262

Browse files
committed
bugfix: *_by_lua_file: did not support absolute file paths on non-UNIX systems like Win32. thanks Someguynamedpie for the report and the original patch in #835.
1 parent d802dbd commit 4b8f262

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

src/ngx_http_lua_util.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -371,37 +371,26 @@ ngx_http_lua_del_thread(ngx_http_request_t *r, lua_State *L,
371371
u_char *
372372
ngx_http_lua_rebase_path(ngx_pool_t *pool, u_char *src, size_t len)
373373
{
374-
u_char *p, *dst;
374+
u_char *p;
375+
ngx_str_t dst;
375376

376-
if (len == 0) {
377+
dst.data = ngx_palloc(pool, len + 1);
378+
if (dst.data == NULL) {
377379
return NULL;
378380
}
379381

380-
if (src[0] == '/') {
381-
/* being an absolute path already */
382-
dst = ngx_palloc(pool, len + 1);
383-
if (dst == NULL) {
384-
return NULL;
385-
}
386-
387-
p = ngx_copy(dst, src, len);
382+
dst.len = len;
388383

389-
*p = '\0';
390-
391-
return dst;
392-
}
384+
p = ngx_copy(dst.data, src, len);
385+
*p = '\0';
393386

394-
dst = ngx_palloc(pool, ngx_cycle->prefix.len + len + 1);
395-
if (dst == NULL) {
387+
if (ngx_get_full_name(pool, (ngx_str_t *) &ngx_cycle->prefix, &dst)
388+
!= NGX_OK)
389+
{
396390
return NULL;
397391
}
398392

399-
p = ngx_copy(dst, ngx_cycle->prefix.data, ngx_cycle->prefix.len);
400-
p = ngx_copy(p, src, len);
401-
402-
*p = '\0';
403-
404-
return dst;
393+
return dst.data;
405394
}
406395

407396

0 commit comments

Comments
 (0)