22/10/2018 10:00, Thomas Monjalon: > 12/09/2018 03:31, Ziye Yang: > > From: Ziye Yang <optimist...@gmail.com> > > > > This patch is used to fix the memory leak issue of logid. > > We use the ASAN test in SPDK when intergrating DPDK and > > find this memory leak issue. > > > > Signed-off-by: Ziye Yang <ziye.y...@intel.com> > > --- > > - logid = strrchr(argv[0], '/'); > > - logid = strdup(logid ? logid + 1: argv[0]); > > - > > + p = strrchr(argv[0], '/'); > > + snprintf(logid, sizeof(logid), "%s", (p ? p + 1 : argv[0])); > > Shouldn't it be strlcpy instead of snprintf?
Applied with suggested replacement: - snprintf(logid, sizeof(logid), "%s", (p ? p + 1 : argv[0])); + strlcpy(logid, p ? p + 1 : argv[0], sizeof(logid));