File 0013-Do-not-write-more-bytes-than-allowed-in-ght_node_to_.patch of Package libght
From fab28d7062907564bb601c723eb09e243cd7b6fe Mon Sep 17 00:00:00 2001
From: Sandro Santilli <strk@keybit.net>
Date: Tue, 3 Feb 2015 12:39:56 +0100
Subject: [PATCH 13/16] Do not write more bytes than allowed in
ght_node_to_nodelist (#13)
---
src/ght_node.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/ght_node.c b/src/ght_node.c
index 2fe3d21..a48e716 100644
--- a/src/ght_node.c
+++ b/src/ght_node.c
@@ -658,7 +658,7 @@ ght_node_read(GhtReader *reader, GhtNode **node)
GhtErr
ght_node_to_nodelist(const GhtNode *node, GhtNodeList *nodelist, GhtAttribute *attr, GhtHash *hash)
{
- static int hash_array_len = GHT_MAX_HASH_LENGTH + 1;
+ static int hash_array_len = GHT_MAX_HASH_LENGTH;
GhtHash h[hash_array_len];
GhtAttribute *a;
@@ -667,6 +667,7 @@ ght_node_to_nodelist(const GhtNode *node, GhtNodeList *nodelist, GhtAttribute *a
strncpy(h, hash, hash_array_len);
if ( node->hash )
{
+ /* TODO: limit write to GHT_MAX_HASH_LENGTH - strlen(node->hash) */
strcat(h, node->hash);
}
@@ -818,4 +819,4 @@ ght_node_filter_by_attribute(const GhtNode *node, const GhtFilter *filter, GhtNo
/* Done, return the structure */
*filtered_node = node_copy;
return GHT_OK;
-}
\ No newline at end of file
+}
--
1.8.4.5