From: Victor Julien Date: Fri, 31 Jan 2014 11:23:53 +0000 (+0100) Subject: Replace remaining SCStrndup calls X-Git-Tag: suricata-2.0rc1~52 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=74fb60c010f7dcc09310d60ea45e1fac8491910d;p=thirdparty%2Fsuricata.git Replace remaining SCStrndup calls Replace them with BytesToString(). --- diff --git a/src/output-json-dns.c b/src/output-json-dns.c index 7dde684324..c3950078b4 100644 --- a/src/output-json-dns.c +++ b/src/output-json-dns.c @@ -119,10 +119,11 @@ static void LogQuery(LogDnsLogThread *aft, json_t *js, DNSTransaction *tx, DNSQu /* query */ char *c; - c = SCStrndup((char *)((char *)entry + sizeof(DNSQueryEntry)), entry->len); - json_object_set_new(djs, "rrname", json_string(c)); - if (c != NULL) + c = BytesToString((uint8_t *)((uint8_t *)entry + sizeof(DNSQueryEntry)), entry->len); + if (c != NULL) { + json_object_set_new(djs, "rrname", json_string(c)); SCFree(c); + } /* name */ char record[16] = ""; @@ -151,10 +152,10 @@ static void OutputAnswer(LogDnsLogThread *aft, json_t *djs, DNSTransaction *tx, /* query */ if (entry->fqdn_len > 0) { char *c; - c = SCStrndup((char *)((char *)entry + sizeof(DNSAnswerEntry)), - entry->fqdn_len); - json_object_set_new(js, "rrname", json_string(c)); + c = BytesToString((uint8_t *)((uint8_t *)entry + sizeof(DNSAnswerEntry)), + entry->fqdn_len); if (c != NULL) { + json_object_set_new(js, "rrname", json_string(c)); SCFree(c); } } diff --git a/src/output-json-file.c b/src/output-json-file.c index c2c6464819..e7df3f4e7f 100644 --- a/src/output-json-file.c +++ b/src/output-json-file.c @@ -49,6 +49,7 @@ #include "util-file.h" #include "util-time.h" #include "util-buffer.h" +#include "util-byte.h" #include "output.h" #include "output-json.h" @@ -190,7 +191,7 @@ static void FileWriteJsonRecord(JsonFileLogThread *aft, const Packet *p, const F return; } - char *s = SCStrndup((char *)ff->name, ff->name_len); + char *s = BytesToString(ff->name, ff->name_len); json_object_set_new(fjs, "filename", json_string(s)); if (s != NULL) SCFree(s);