Commit e485b36c by Serge Hallyn Committed by GitHub

Merge pull request #1861 from brauner/2017-10-16/fix_log_stack_smash

log: bugfixes
parents 59262374 a427e268
......@@ -2701,9 +2701,6 @@ int lxc_map_ids(struct lxc_list *idmap, pid_t pid)
pos += sprintf(mapbuf, "new%cidmap %d", u_or_g, pid);
lxc_list_for_each(iterator, idmap) {
/* The kernel only takes <= 4k for writes to
* /proc/<nr>/[ug]id_map
*/
map = iterator->elem;
if (map->idtype != type)
continue;
......@@ -2715,8 +2712,13 @@ int lxc_map_ids(struct lxc_list *idmap, pid_t pid)
use_shadow ? " " : "", map->nsid,
map->hostid, map->range,
use_shadow ? "" : "\n");
if (fill <= 0 || fill >= left)
SYSERROR("Too many {g,u}id mappings defined.");
if (fill <= 0 || fill >= left) {
/* The kernel only takes <= 4k for writes to
* /proc/<pid>/{g,u}id_map
*/
SYSERROR("Too many %cid mappings defined", u_or_g);
return -1;
}
pos += fill;
}
......
......@@ -297,7 +297,8 @@ static int log_append_logfile(const struct lxc_log_appender *appender,
if ((size_t)n < (sizeof(buffer) - 1))
n += vsnprintf(buffer + n, sizeof(buffer) - n, event->fmt, *event->vap);
else
if ((size_t)n >= sizeof(buffer))
n = sizeof(buffer) - 1;
buffer[n] = '\n';
......
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