With this change, vdi_setattr() duplicates value which is passed via command line with xstrdup(). With this change, dog can free() the value unconditionally. It makes the intention of the code clear.
Reported-by: Ruoyu <lian...@ucweb.com> Cc: Ruoyu <lian...@ucweb.com> Signed-off-by: Hitoshi Mitake <mitake.hito...@lab.ntt.co.jp> --- dog/vdi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dog/vdi.c b/dog/vdi.c index 84715b3..cd85b65 100644 --- a/dog/vdi.c +++ b/dog/vdi.c @@ -1286,7 +1286,8 @@ static int vdi_setattr(int argc, char **argv) goto out; } - value = argv[optind++]; + value = argv[optind] ? xstrdup(argv[optind]) : NULL; + optind++; if (!value && !vdi_cmd_data.delete) { value = xmalloc(SD_MAX_VDI_ATTR_VALUE_LEN); -- 1.8.3.2 -- sheepdog mailing list sheepdog@lists.wpkg.org http://lists.wpkg.org/mailman/listinfo/sheepdog