~ubuntu-vzuijlekom/nginx/debian-1.6.2-5

« back to all changes in this revision

Viewing changes to debian/modules/nginx-lua/src/ngx_http_lua_variable.c

  • Committer: ChillyWilly
  • Date: 2018-04-26 07:30:09 UTC
  • Revision ID: ubuntu@vzuijlekom.com-20180426073009-he87c3vxq2mpsbji
upgraded modules nginx-lua and headers-more-nginx

Show diffs side-by-side

added added

removed removed

Lines of Context:
185
185
 
186
186
        val = ngx_palloc(r->pool, len);
187
187
        if (val == NULL) {
188
 
            return luaL_error(L, "memory allocation erorr");
 
188
            return luaL_error(L, "memory allocation error");
189
189
        }
190
190
 
191
191
        ngx_memcpy(val, p, len);
307
307
        return NGX_ERROR;
308
308
    }
309
309
 
310
 
    if ((r)->connection->fd == -1) {
 
310
    if ((r)->connection->fd == (ngx_socket_t) -1) {
311
311
        *err = "API disabled in the current context";
312
312
        return NGX_ERROR;
313
313
    }
364
364
int
365
365
ngx_http_lua_ffi_var_set(ngx_http_request_t *r, u_char *name_data,
366
366
    size_t name_len, u_char *lowcase_buf, u_char *value, size_t value_len,
367
 
    u_char *errbuf, size_t errlen)
 
367
    u_char *errbuf, size_t *errlen)
368
368
{
369
369
    u_char                      *p;
370
370
    ngx_uint_t                   hash;
373
373
    ngx_http_core_main_conf_t   *cmcf;
374
374
 
375
375
    if (r == NULL) {
376
 
        ngx_snprintf(errbuf, errlen, "no request object found");
 
376
        *errlen = ngx_snprintf(errbuf, *errlen, "no request object found")
 
377
                  - errbuf;
377
378
        return NGX_ERROR;
378
379
    }
379
380
 
380
 
    if ((r)->connection->fd == -1) {
381
 
        ngx_snprintf(errbuf, errlen, "API disabled in the current context");
 
381
    if ((r)->connection->fd == (ngx_socket_t) -1) {
 
382
        *errlen = ngx_snprintf(errbuf, *errlen,
 
383
                               "API disabled in the current context")
 
384
                  - errbuf;
382
385
        return NGX_ERROR;
383
386
    }
384
387
 
395
398
    if (v) {
396
399
        if (!(v->flags & NGX_HTTP_VAR_CHANGEABLE)) {
397
400
            dd("variable not changeable");
398
 
            ngx_snprintf(errbuf, errlen, "variable \"%*s\" not changeable",
399
 
                         name_len, lowcase_buf);
 
401
            *errlen = ngx_snprintf(errbuf, *errlen,
 
402
                                   "variable \"%*s\" not changeable",
 
403
                                   name_len, lowcase_buf)
 
404
                      - errbuf;
400
405
            return NGX_ERROR;
401
406
        }
402
407
 
405
410
            dd("set variables with set_handler");
406
411
 
407
412
            if (value != NULL && value_len) {
408
 
                vv = ngx_pnalloc(r->pool, sizeof(ngx_http_variable_value_t)
409
 
                                 + value_len);
 
413
                vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)
 
414
                                + value_len);
410
415
                if (vv == NULL) {
411
416
                    goto nomem;
412
417
                }
460
465
                if (p == NULL) {
461
466
                    goto nomem;
462
467
                }
 
468
 
463
469
                ngx_memcpy(p, value, value_len);
464
470
                value = p;
465
471
 
474
480
            return NGX_OK;
475
481
        }
476
482
 
477
 
        ngx_snprintf(errbuf, errlen, "variable \"%*s\" cannot be assigned "
478
 
                     "a value", name_len, lowcase_buf);
 
483
        *errlen = ngx_snprintf(errbuf, *errlen,
 
484
                               "variable \"%*s\" cannot be assigned "
 
485
                               "a value", name_len, lowcase_buf)
 
486
                  - errbuf;
479
487
        return NGX_ERROR;
480
488
    }
481
489
 
482
490
    /* variable not found */
483
491
 
484
 
    ngx_snprintf(errbuf, errlen, "variable \"%*s\" not found for writing; "
485
 
                 "maybe it is a built-in variable that is not changeable "
486
 
                 "or you forgot to use \"set $%*s '';\" "
487
 
                 "in the config file to define it first",
488
 
                 name_len, lowcase_buf, name_len, lowcase_buf);
 
492
    *errlen = ngx_snprintf(errbuf, *errlen,
 
493
                           "variable \"%*s\" not found for writing; "
 
494
                           "maybe it is a built-in variable that is not "
 
495
                           "changeable or you forgot to use \"set $%*s '';\" "
 
496
                           "in the config file to define it first",
 
497
                           name_len, lowcase_buf, name_len, lowcase_buf)
 
498
              - errbuf;
489
499
    return NGX_ERROR;
490
500
 
491
501
nomem:
492
502
 
493
 
    ngx_snprintf(errbuf, errlen, "no memory");
 
503
    *errlen = ngx_snprintf(errbuf, *errlen, "no memory") - errbuf;
494
504
    return NGX_ERROR;
495
505
}
496
506
#endif /* NGX_LUA_NO_FFI_API */