From: Miek Gieben Date: Thu, 11 Aug 2005 14:29:22 +0000 (+0000) Subject: bogus malloc to pinpoint crash X-Git-Tag: release-1.0.0~294 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9f3beff041b36b9b973eeec10ecc8c0a106d080d;p=thirdparty%2Fldns.git bogus malloc to pinpoint crash --- diff --git a/lua/lua-rns.c b/lua/lua-rns.c index e6d6f8fe..dfdc13d3 100644 --- a/lua/lua-rns.c +++ b/lua/lua-rns.c @@ -314,15 +314,22 @@ l_read_wire_udp(lua_State *L) ldns_pkt *pkt; ldns_buffer *pktbuf; + pktbuf_raw = LDNS_XMALLOC(uint8_t, LDNS_MAX_PACKETLEN); + if (!pktbuf_raw) { + return 0; + } + pktbuf_raw = ldns_udp_read_wire(sockfd, &size); - if (!pktbuf_raw) { printf("[debug] nothing allright\n"); return 0; } + /* will be freeed in a minute ... */ + /*pktbuf_raw = (uint8_t*)LDNS_XREALLOC(pktbuf_raw, uint8_t *, size); */ + ldns_buffer_new_frm_data(pktbuf, pktbuf_raw, size); - LDNS_FREE(pktbuf_raw); +/* LDNS_FREE(pktbuf_raw);*/ /* push our buffer onto the stack */ printf("[debug] I've read %d bytes\n", size); diff --git a/lua/lua-todo b/lua/lua-todo index 34410899..d709786d 100644 --- a/lua/lua-todo +++ b/lua/lua-todo @@ -1,3 +1,3 @@ -free functions from ldns - sometimes they are needed +fix segfault -read packet from socket +fix pkt printing its id: diff --git a/lua/rns.lua b/lua/rns.lua index e5f43fd8..6a260240 100644 --- a/lua/rns.lua +++ b/lua/rns.lua @@ -54,10 +54,8 @@ l_server_socket_close_udp(socket) -- convert the packet ---if not wirebuf == nil then --- lua_debug("I shouldn't be here") --- wirepkt = l_buf2pkt(wirebuf) --- -- print the packet --- l_pkt_print(wirepkt) ---end + lua_debug("I shouldn't be here") + wirepkt = l_buf2pkt(wirebuf) + -- print the packet + l_pkt_print(wirepkt) lua_debug("The end")