forked from osmocom/wireshark
Always memset the packet-header struct in Lua to avoid
crashes from garbage data. Also, give Lua a copy of the packet comment if there is one. Fixes: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7538 svn path=/trunk/; revision=44093
This commit is contained in:
parent
98bbc5a3d9
commit
1457a01f49
|
@ -291,13 +291,18 @@ WSLUA_METHOD Dumper_dump(lua_State* L) {
|
||||||
|
|
||||||
if (! ba) WSLUA_ARG_ERROR(Dumper_dump,BYTEARRAY,"must be a ByteArray");
|
if (! ba) WSLUA_ARG_ERROR(Dumper_dump,BYTEARRAY,"must be a ByteArray");
|
||||||
|
|
||||||
pkthdr.ts.secs = (unsigned)floor(ts);
|
memset(&pkthdr, 0, sizeof(pkthdr));
|
||||||
|
|
||||||
|
pkthdr.ts.secs = (unsigned)floor(ts);
|
||||||
pkthdr.ts.nsecs = (unsigned)floor((ts - (double)pkthdr.ts.secs) * 1000000000);
|
pkthdr.ts.nsecs = (unsigned)floor((ts - (double)pkthdr.ts.secs) * 1000000000);
|
||||||
|
|
||||||
pkthdr.len = ba->len;
|
pkthdr.len = ba->len;
|
||||||
pkthdr.caplen = ba->len;
|
pkthdr.caplen = ba->len;
|
||||||
pkthdr.pkt_encap = DUMPER_ENCAP(d);
|
pkthdr.pkt_encap = DUMPER_ENCAP(d);
|
||||||
|
|
||||||
|
/* TODO: Can we get access to pinfo->fd->opt_comment here somehow? We
|
||||||
|
* should be copying it to pkthdr.opt_comment if we can. */
|
||||||
|
|
||||||
if (! wtap_dump(d, &pkthdr, ph->wph, ba->data, &err)) {
|
if (! wtap_dump(d, &pkthdr, ph->wph, ba->data, &err)) {
|
||||||
luaL_error(L,"error while dumping: %s",
|
luaL_error(L,"error while dumping: %s",
|
||||||
wtap_strerror(err));
|
wtap_strerror(err));
|
||||||
|
@ -370,12 +375,17 @@ WSLUA_METHOD Dumper_dump_current(lua_State* L) {
|
||||||
|
|
||||||
tvb = data_src->tvb;
|
tvb = data_src->tvb;
|
||||||
|
|
||||||
pkthdr.ts.secs = lua_pinfo->fd->abs_ts.secs;
|
memset(&pkthdr, 0, sizeof(pkthdr));
|
||||||
pkthdr.ts.nsecs = lua_pinfo->fd->abs_ts.nsecs;
|
|
||||||
pkthdr.len = tvb_reported_length(tvb);
|
pkthdr.ts.secs = lua_pinfo->fd->abs_ts.secs;
|
||||||
pkthdr.caplen = tvb_length(tvb);
|
pkthdr.ts.nsecs = lua_pinfo->fd->abs_ts.nsecs;
|
||||||
|
pkthdr.len = tvb_reported_length(tvb);
|
||||||
|
pkthdr.caplen = tvb_length(tvb);
|
||||||
pkthdr.pkt_encap = lua_pinfo->fd->lnk_t;
|
pkthdr.pkt_encap = lua_pinfo->fd->lnk_t;
|
||||||
|
|
||||||
|
if (lua_pinfo->fd->opt_comment)
|
||||||
|
pkthdr.opt_comment = ep_strdup(lua_pinfo->fd->opt_comment);
|
||||||
|
|
||||||
data = ep_tvb_memdup(tvb,0,pkthdr.caplen);
|
data = ep_tvb_memdup(tvb,0,pkthdr.caplen);
|
||||||
|
|
||||||
if (! wtap_dump(d, &pkthdr, lua_pinfo->pseudo_header, data, &err)) {
|
if (! wtap_dump(d, &pkthdr, lua_pinfo->pseudo_header, data, &err)) {
|
||||||
|
|
Loading…
Reference in New Issue