cmdline: check size of result buffer to avoid overflow
[libcmdline.git] / src / genconf / confnode_choice.c
index 892e634..cb36658 100644 (file)
@@ -150,6 +150,8 @@ static int confnode_choice_set_user_strvalue(struct confnode *n,
 static int confnode_choice_get_user_strvalue(const struct confnode *n, char *buf,
                                              unsigned buflen)
 {
+       if (strcmp("", n->value) == 0)
+               return -1;
        snprintf(buf, buflen, n->value);
        return 0;
 }
@@ -199,7 +201,7 @@ static void confnode_choice_display_short(const struct confnode *n)
 {
        char buf[BUFSIZ];
 
-       printf("choice %s ", n->name);
+       printf("choice -> %s ", n->name);
        if (confnode_get_value(n, buf, sizeof(buf)) >= 0) {
                if (strlen(buf) > MAX_DISP_SIZE) {
                        buf[MAX_DISP_SIZE-3] = '.';