Unverified Commit 27b54094 by Christian Brauner Committed by GitHub

Merge pull request #1935 from flx42/confile-overlapping-strncpy

confile_utils: fix overlapping strncpy
parents ba715de0 ee3e84df
......@@ -567,7 +567,8 @@ bool lxc_config_net_hwaddr(const char *line)
return false;
}
/* strlen("hwaddr") = 6 */
strncpy(copy + 8, p + 1, 6);
if (strlen(p + 1) >= 6)
memmove(copy + 8, p + 1, 6);
copy[8 + 6] = '\0';
}
if (strncmp(copy, "lxc.net.hwaddr", 14) == 0) {
......@@ -591,7 +592,8 @@ bool lxc_config_net_hwaddr(const char *line)
return false;
}
/* strlen("hwaddr") = 6 */
strncpy(copy + 12, p + 1, 6);
if (strlen(p + 1) >= 6)
memmove(copy + 12, p + 1, 6);
copy[12 + 6] = '\0';
}
if (strncmp(copy, "lxc.network.hwaddr", 18) == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment