Signed-off-by: Christian Franke <[email protected]>
---
 isisd/isis_lsp.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c
index 8f7fc0a..cdf78cb 100644
--- a/isisd/isis_lsp.c
+++ b/isisd/isis_lsp.c
@@ -1228,9 +1228,13 @@ lsp_build (struct isis_lsp *lsp, struct isis_area *area)
       lsp->tlv_data.hostname = XMALLOC (MTYPE_ISIS_TLV,
                                        sizeof (struct hostname));
 
-      memcpy (lsp->tlv_data.hostname->name, unix_hostname (),
-             strlen (unix_hostname ()));
-      lsp->tlv_data.hostname->namelen = strlen (unix_hostname ());
+      strncpy((char *)lsp->tlv_data.hostname->name, unix_hostname(),
+              sizeof(lsp->tlv_data.hostname->name));
+      if (strlen(unix_hostname()) <= 255)
+        lsp->tlv_data.hostname->namelen = strlen(unix_hostname());
+      else
+        lsp->tlv_data.hostname->namelen = 255;
+
       tlv_add_dynamic_hostname (lsp->tlv_data.hostname, lsp->pdu);
     }
 
-- 
2.6.1


_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to