From ca16811c74527d28659bdd31a9da1968e3281e30 Mon Sep 17 00:00:00 2001
From: David Moreau <david.moreau@thalesaleniaspace.com>
Date: Mon, 22 Jul 2013 11:26:57 +0200
Subject: [PATCH 5/5] Fix: add null character after strncpy

Regression due to commit 68942bc7444db1ffe8356d552688b0bf74a07fb5.
The null character was never copied.
If a short string ("aa" for example) is set after a long ("llll") the
result was : "aall".
---
 tmpl/bb.yaml |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/tmpl/bb.yaml b/tmpl/bb.yaml
index 8d911a2..db39f6e 100644
--- a/tmpl/bb.yaml
+++ b/tmpl/bb.yaml
@@ -222,6 +222,7 @@ table_setter_chartab: |+
                   len = sizeof(<%= bbname %>-><%= table_name %>[idx].<%= name %>);
           bb_lock(bb_<%= bbname %>);
           strncpy(<%= bbname %>-><%= table_name %>[idx].<%= name %>, value, len - 1);
+         <%= bbname %>-><%= table_name %>[idx].<%= name %>[len - 1] = '\0';
           bb_unlock(bb_<%= bbname %>);
   }
 
@@ -611,6 +612,7 @@ setter_chartab: |
       len = sizeof(<%= bbname %>-><%= name %>);
     bb_lock(bb_<%= bbname %>);
     strncpy(<%= bbname %>-><%= name %>, value, len - 1);
+    <%= bbname %>-><%= name %>[len - 1] = '\0';
     bb_unlock(bb_<%= bbname %>);
   }
 
-- 
1.7.1

