File 0015-Ensure-hash-is-null-terminated-in-ght_node_to_nodeli.patch of Package libght

From 31108dfc3a0d0ca9229146da18bf0cfe35ba5b41 Mon Sep 17 00:00:00 2001
From: Sandro Santilli <strk@keybit.net>
Date: Tue, 3 Feb 2015 13:14:51 +0100
Subject: [PATCH 15/16] Ensure hash is null terminated in ght_node_to_nodelist

---
 src/ght_node.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/ght_node.c b/src/ght_node.c
index a48e716..65f1a57 100644
--- a/src/ght_node.c
+++ b/src/ght_node.c
@@ -658,13 +658,13 @@ 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;
+    static int hash_array_len = GHT_MAX_HASH_LENGTH+1;
     GhtHash h[hash_array_len];
     GhtAttribute *a;
     
     /* Add our part of the hash to the incoming part */
     memset(h, 0, hash_array_len);
-    strncpy(h, hash, hash_array_len);
+    strncpy(h, hash, GHT_MAX_HASH_LENGTH);
     if ( node->hash )
     {
         /* TODO: limit write to GHT_MAX_HASH_LENGTH - strlen(node->hash) */
-- 
1.8.4.5
openSUSE Build Service is sponsored by