diff --git a/src/keccak.c b/src/keccak.c index 201af68..9b06537 100644 --- a/src/keccak.c +++ b/src/keccak.c @@ -30,6 +30,7 @@ void KeccakF1600(void *s) void Keccak(ui r, ui c, const u8 *in, u64 inLen, u8 sfx, u8 *out, u64 outLen) { /*initialize*/ u8 s[200]; ui R=r/8; ui i,b=0; FOR(i,200) s[i]=0; + /*san-check*/ if (((r+c)!= 1600) || ((r % 8 ) != 0)) return; /*absorb*/ while(inLen>0) { b=(inLen0) { b=(outLen0) KeccakF1600(s); } diff --git a/src/libkore.c b/src/libkore.c index cae519f..0965d3e 100644 --- a/src/libkore.c +++ b/src/libkore.c @@ -77,7 +77,7 @@ coroutine_iter_sent(struct netbuf *buf){ return coroutine_iter_next(obj); } } -const char response[] = "0\r\n\r\n"; +char response[] = "0\r\n\r\n"; int coroutine_iter_next(struct co_obj *obj){ printf("Coroutine iter next called\n"); @@ -99,6 +99,10 @@ int coroutine_iter_next(struct co_obj *obj){ luaL_checktype(L,-1,LUA_TTHREAD); printf("About to call resume()\n"); int err = lua_pcall(L,1,2,0); + if(err != 0){ + printf("Call error: %d\n",err); + return (KORE_RESULT_ERROR); + } printf("Done calling resume()\n"); if(!lua_toboolean(L,-2)){ //Runtime error printf("Runtime error\n"); @@ -126,7 +130,7 @@ int coroutine_iter_next(struct co_obj *obj){ size_t size; const char *data = luaL_checklstring(L,-1,&size); struct netbuf *nb; - printf("Yielding data stream size %lld\n",size); + printf("Yielding data stream size %zu\n",size); struct kore_buf *kb = kore_buf_alloc(0); kore_buf_appendf(kb,"%x\r\n",size); kore_buf_append(kb,data,size); @@ -167,6 +171,7 @@ coroutine_disconnect(struct connection *c){ The coroutine passed to this function should yield() the data to send to the client, then return when done. +TODO: Broken and leaks memory http_response_co(request::userdata, co::coroutine) */ int @@ -187,6 +192,7 @@ lhttp_response_co(lua_State *L){ http_response(req,200,NULL,0); coroutine_iter_next(obj); printf("Done calling iter next\n"); + return 0; } /* @@ -438,6 +444,7 @@ lhttp_set_flags(lua_State *L){ struct http_request *req = luaL_checkrequest(L,-2); lua_pop(L,2); req->flags = flags; + return 0; } /* @@ -448,6 +455,7 @@ lhttp_get_flags(lua_State *L){ struct http_request *req = luaL_checkrequest(L,-1); lua_pop(L,1); lua_pushnumber(L,req->flags); + return 1; } /* diff --git a/src/libkore.h b/src/libkore.h index 6cfd984..55279f3 100644 --- a/src/libkore.h +++ b/src/libkore.h @@ -5,9 +5,11 @@ struct co_obj { struct connection *c; }; int lhttp_response(lua_State *L); +int lhttp_response_co(lua_State *L); int coroutine_iter_sent(struct netbuf *buf); int coroutine_iter_next(struct co_obj *obj); int lhttp_response_header(lua_State *L); +int lhttp_request_header(lua_State *L); int lhttp_method_text(lua_State *L); int lhttp_request_get_path(lua_State *L); int lhttp_request_get_host(lua_State *L); @@ -19,6 +21,8 @@ int lhttp_argument_get_string(lua_State *L); int lhttp_request_get_ip(lua_State *L); int lhttp_populate_cookies(lua_State *L); int lhttp_file_get(lua_State *L); +int lhttp_set_flags(lua_State *L); +int lhttp_get_flags(lua_State *L); int lhttp_populate_multipart_form(lua_State *L); int lkore_log(lua_State *L); void load_kore_libs(lua_State *L);