]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/command.c
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / lib / command.c
index 27cd3a04bd610b3d00734c96cbe43082c85b90f8..099563721902666f493661f173f2a0b90ea47b97 100644 (file)
@@ -735,9 +735,13 @@ char *cmd_variable_comp2str(vector comps, unsigned short cols)
                char *item = vector_slot(comps, j);
                itemlen = strlen(item);
 
-               if (cs + itemlen + AUTOCOMP_INDENT + 3 >= bsz)
-                       buf = XREALLOC(MTYPE_TMP, buf, (bsz *= 2));
+               size_t next_sz = cs + itemlen + AUTOCOMP_INDENT + 3;
 
+               if (next_sz > bsz) {
+                       /* Make sure the buf size is large enough */
+                       bsz = next_sz;
+                       buf = XREALLOC(MTYPE_TMP, buf, bsz);
+               }
                if (lc + itemlen + 1 >= cols) {
                        cs += snprintf(&buf[cs], bsz - cs, "\n%*s",
                                       AUTOCOMP_INDENT, "");
@@ -1283,6 +1287,7 @@ int command_config_read_one_line(struct vty *vty,
 
                memcpy(ve->error_buf, vty->buf, VTY_BUFSIZ);
                ve->line_num = line_num;
+               ve->cmd_ret = ret;
                if (!vty->error)
                        vty->error = list_new();
 
@@ -1303,6 +1308,14 @@ int config_from_file(struct vty *vty, FILE *fp, unsigned int *line_num)
        while (fgets(vty->buf, VTY_BUFSIZ, fp)) {
                ++(*line_num);
 
+               if (vty_log_commands) {
+                       int len = strlen(vty->buf);
+
+                       /* now log the command */
+                       zlog_notice("config-from-file# %.*s", len ? len - 1 : 0,
+                                   vty->buf);
+               }
+
                ret = command_config_read_one_line(vty, NULL, *line_num, 0);
 
                if (ret != CMD_SUCCESS && ret != CMD_WARNING