From 55e182b5b323c049ea49c79c2d68c8547940c62b Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Tue, 29 Jun 2021 19:51:06 +0200 Subject: ipcpd: Fix layer info RIB Layer info was not converted to parse the full path with the latest RIB change. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/ipcp.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index 65a28d61..59fbdba6 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -103,10 +103,15 @@ static int ipcp_rib_read(const char * path, char * buf, size_t len) { + char * entry; + if (len < LAYER_NAME_SIZE + 2) /* trailing \n */ return 0; - if (strcmp(path, info[0]) == 0) { /* _state */ + entry = strstr(path, RIB_SEPARATOR) + 1; + assert(entry); + + if (strcmp(entry, info[0]) == 0) { /* _state */ enum ipcp_state state = ipcp_get_state(); if (state == IPCP_NULL) strcpy(buf, "null\n"); @@ -120,7 +125,7 @@ static int ipcp_rib_read(const char * path, strcpy(buf, "bug\n"); } - if (strcmp(path, info[1]) == 0) { /* _type */ + if (strcmp(entry, info[1]) == 0) { /* _type */ if (ipcpi.type == IPCP_LOCAL) strcpy(buf, "local\n"); else if (ipcpi.type == IPCP_UNICAST) @@ -137,7 +142,7 @@ static int ipcp_rib_read(const char * path, strcpy(buf, "bug\n"); } - if (strcmp(path, info[2]) == 0) { /* _layer */ + if (strcmp(entry, info[2]) == 0) { /* _layer */ memset(buf, 0, LAYER_NAME_SIZE + 1); if (ipcp_get_state() < IPCP_OPERATIONAL) strcpy(buf, "(null)"); -- cgit v1.2.3