Mercurial > urweb
comparison src/c/urweb.c @ 1998:cc7e5d469d1b
Protect uw_Basis_new_client_source from invalid ctx->id
We assume that FFI code may create new contextes with id left unassigned
author | Sergey Mironov <grrwlf@gmail.com> |
---|---|
date | Wed, 26 Feb 2014 09:43:47 +0000 |
parents | c93fbd139732 |
children | bddee3af70c4 |
comparison
equal
deleted
inserted
replaced
1997:c93fbd139732 | 1998:cc7e5d469d1b |
---|---|
1583 } | 1583 } |
1584 | 1584 |
1585 uw_Basis_source uw_Basis_new_client_source(uw_context ctx, uw_Basis_string s) { | 1585 uw_Basis_source uw_Basis_new_client_source(uw_context ctx, uw_Basis_string s) { |
1586 int len; | 1586 int len; |
1587 size_t s_len = strlen(s); | 1587 size_t s_len = strlen(s); |
1588 | |
1589 if(ctx->id < 0) | |
1590 uw_error(ctx, FATAL, "Attempt to create client source using inappropriate context"); | |
1588 | 1591 |
1589 uw_check_script(ctx, 15 + 2 * INTS_MAX + s_len); | 1592 uw_check_script(ctx, 15 + 2 * INTS_MAX + s_len); |
1590 sprintf(ctx->script.front, "s%d_%llu=sc(exec(%n", ctx->id, ctx->source_count, &len); | 1593 sprintf(ctx->script.front, "s%d_%llu=sc(exec(%n", ctx->id, ctx->source_count, &len); |
1591 ctx->script.front += len; | 1594 ctx->script.front += len; |
1592 strcpy(ctx->script.front, s); | 1595 strcpy(ctx->script.front, s); |