From: Daniel Walton Date: Fri, 16 Oct 2015 20:53:03 +0000 (+0000) Subject: quagga crashes on 'show run bgp' X-Git-Tag: frr-2.0-rc1~1234 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=f35a5350975a943f4f219fcb708e2e5ef15597e1;p=matthieu%2Ffrr.git quagga crashes on 'show run bgp' Signed-off-by: Daniel Walton Reviewed-by: Donald Sharp --- diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 6d5f3c9e9a..54e3e4f6c6 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -101,6 +101,19 @@ vclient_close (struct vtysh_client *vclient) } } +/* Return true if str begins with prefix, else return false */ +static int +begins_with(const char *str, const char *prefix) +{ + if (!str || !prefix) + return 0; + size_t lenstr = strlen(str); + size_t lenprefix = strlen(prefix); + if (lenprefix > lenstr) + return 0; + return strncmp(str, prefix, lenprefix) == 0; +} + /* Following filled with debug code to trace a problematic condition * under load - it SHOULD handle it. */ #define ERR_WHERE_STRING "vtysh(): vtysh_client_config(): " @@ -1999,7 +2012,7 @@ DEFUN (vtysh_write_terminal_daemon, for (i = 0; i < array_size(vtysh_client); i++) { - if (strcmp(vtysh_client[i].name, argv[0]) == 0) + if (begins_with(vtysh_client[i].name, argv[0])) break; } @@ -2492,19 +2505,6 @@ vtysh_connect (struct vtysh_client *vclient) return 0; } -/* Return true if str begins with prefix, else return false */ -static int -begins_with(const char *str, const char *prefix) -{ - if (!str || !prefix) - return 0; - size_t lenstr = strlen(str); - size_t lenprefix = strlen(prefix); - if (lenprefix > lenstr) - return 0; - return strncmp(str, prefix, lenprefix) == 0; -} - /* Return true if str ends with suffix, else return false */ static int ends_with(const char *str, const char *suffix)