giop: don't use packet scope for allocating a buffer at init time.

You can't use packet scope if you're not dissecting a packet;
read_IOR_strings_from_file() is called from giop_init(), which is called
when a file is opened, not when dissecting a packet.

Use NULL as the scope, which just does a regular allocation, and free
the buffer when we're done.

Expand a comment to indicate that using dissection routines is *also* a
bad idea in code that's not used when dissecting packets.

Fixes #16984.


(cherry picked from commit 2c2ee172eb)
This commit is contained in:
Guy Harris 2020-11-05 00:37:30 +00:00
parent 5cac5d3254
commit 99238a0198
1 changed files with 9 additions and 5 deletions

View File

@ -1542,7 +1542,7 @@ static void read_IOR_strings_from_file(const gchar *name, int max_iorlen) {
return; return;
} }
buf = (gchar *)wmem_alloc0(wmem_packet_scope(), max_iorlen+1); /* input buf */ buf = (gchar *)wmem_alloc0(NULL, max_iorlen+1); /* input buf */
while ((len = giop_getline(fp, buf, max_iorlen+1)) > 0) { while ((len = giop_getline(fp, buf, max_iorlen+1)) > 0) {
my_offset = 0; /* reset for every IOR read */ my_offset = 0; /* reset for every IOR read */
@ -1551,10 +1551,12 @@ static void read_IOR_strings_from_file(const gchar *name, int max_iorlen) {
if (ior_val_len>0) { if (ior_val_len>0) {
/* XXX - can this throw an exception in this case? If so, we /* XXX - can this code throw an exception? If so, we need to
need to catch it and clean up, but we really shouldn't allow catch it and clean up, but we really shouldn't allow it - or
it - or "get_CDR_octet()", or "decode_IOR()" - to throw an "get_CDR_octet()", or "decode_IOR()" - to throw an exception.
exception. */
Either that, or don't reuse dissector code when we're not
dissecting a packet. */
tvb = tvb_new_real_data(out, ior_val_len, ior_val_len); tvb = tvb_new_real_data(out, ior_val_len, ior_val_len);
@ -1567,6 +1569,8 @@ static void read_IOR_strings_from_file(const gchar *name, int max_iorlen) {
} }
fclose(fp); /* be nice */ fclose(fp); /* be nice */
wmem_free(NULL, buf);
} }