From b7dc77312720bb1bfa3698f3b48e21c991c49632 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 12 Jan 2016 20:10:05 -0800 Subject: Assorted cleanups. Fix indentation. Just directly assign values to elements in the packet buffer; no need to convert them to numbers and note the value as a comment. Give more detail in the comment for null-terminating buffers. Terminate packet_buf[] once we're finished reading into it, to make it a bit clearer what's being done. Make the magic number buffer 513 bytes, so we have 512 bytes plus a terminating null. Change-Id: Ie182d93393cc55835b24075e908393c386c85c24 Reviewed-on: https://code.wireshark.org/review/13250 Reviewed-by: Guy Harris --- wiretap/nettrace_3gpp_32_423.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'wiretap') diff --git a/wiretap/nettrace_3gpp_32_423.c b/wiretap/nettrace_3gpp_32_423.c index ea4abffd0e..5e80584479 100644 --- a/wiretap/nettrace_3gpp_32_423.c +++ b/wiretap/nettrace_3gpp_32_423.c @@ -723,17 +723,15 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ * + End of options 4 bytes */ /* XXX add the length of exported bdu tag(s) here */ - packet_buf = (guint8 *)g_malloc(packet_size + 12+1); - /* Terminate buffer*/ - packet_buf[packet_size + 12] = 0; + packet_buf = (guint8 *)g_malloc(packet_size + 12 + 1); packet_buf[0] = 0; - packet_buf[1] = 12; /* EXP_PDU_TAG_PROTO_NAME */ + packet_buf[1] = EXP_PDU_TAG_PROTO_NAME; packet_buf[2] = 0; packet_buf[3] = 4; - packet_buf[4] = 0x78; /* "x" */ - packet_buf[5] = 0x6d; /* "m" */ - packet_buf[6] = 0x6c; /* "l" */ + packet_buf[4] = 'x'; + packet_buf[5] = 'm'; + packet_buf[6] = 'l'; packet_buf[7] = 0; /* End of options */ packet_buf[8] = 0; @@ -741,12 +739,14 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ packet_buf[10] = 0; packet_buf[11] = 0; - if (!wtap_read_bytes(wth->fh, packet_buf + 12, packet_size, &wrt_err, &wrt_err_info)){ result = WTAP_OPEN_ERROR; goto end; } + /* Null-terminate buffer; we'll be processing it as a string. */ + packet_buf[packet_size + 12] = '\0'; + /* Create the packet header */ memset(&phdr, 0, sizeof(struct wtap_pkthdr)); @@ -772,7 +772,6 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ phdr.caplen = packet_size + 12; phdr.len = packet_size + 12; - /* XXX: report errors! */ if (!wtap_dump(wdh_exp_pdu, &phdr, packet_buf, &wrt_err, &wrt_err_info)) { switch (wrt_err) { @@ -789,7 +788,6 @@ create_temp_pcapng_file(wtap *wth, int *err, gchar **err_info, nettrace_3gpp_32_ goto end; } - /* Lets add the raw messages as packets after the main "packet" with the whole file */ while ((curr_pos = strstr(curr_pos, "