I'm not a big fan of repeatedly calling unix_hostname().
Additionally in one case you use sizeof(lsp->tlv_data.hostname->name) and
in other cases you test against 255 and then set it to that.
Why not use a #define and clear all that up?
isis_common.h:
struct hostname
{
#define ISIS_MAX_HOSTNAME_LEN 255
u_char namelen;
u_char name[ISIS_MAX_HOSTNAME_LEN];
};
Then the rest of the diff simplifies falls from that.
donald
On Tue, Nov 10, 2015 at 12:04 PM, Christian Franke <
[email protected]> wrote:
> 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
>
_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev