]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Replace remaining SCStrndup calls
authorVictor Julien <victor@inliniac.net>
Fri, 31 Jan 2014 11:23:53 +0000 (12:23 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 31 Jan 2014 12:32:32 +0000 (13:32 +0100)
Replace them with BytesToString().

src/output-json-dns.c
src/output-json-file.c

index 7dde684324e21e33e97eaec387f3aa73777104e7..c3950078b4458ede4c5e8ff0acf751d82e4fd623 100644 (file)
@@ -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);
             }
         }
index c2c6464819d1774eb0cbcaa3b3c700744a635344..e7df3f4e7fd67912e28d1fb3284cfb1431bb3ed8 100644 (file)
@@ -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);