confd: fix segfault when calling 'no dhcp-client'

Fixes #384

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2024-04-11 06:19:07 +02:00
parent c182fd43a8
commit 140379190c
+7 -2
View File
@@ -384,9 +384,8 @@ static int cand(sr_session_ctx_t *session, uint32_t sub_id, const char *module,
return err;
while (sr_get_change_next(session, iter, &op, &old, &new) == SR_ERR_OK) {
char xpath[strlen(new->xpath) + 42];
char *xpath, *ptr;
size_t cnt = 0;
char *ptr;
switch (op) {
case SR_OP_CREATED:
@@ -396,6 +395,12 @@ static int cand(sr_session_ctx_t *session, uint32_t sub_id, const char *module,
continue;
}
xpath = strdupa(new->xpath);
if (!xpath) {
ERRNO("Failed strdupa()");
return SR_ERR_SYS;
}
strlcpy(xpath, new->xpath, sizeof(xpath));
if ((ptr = strstr(xpath, "]/")) == NULL)
continue;