Skip to content

Commit

Permalink
fix: unprivileged veth devices (e.g. vethFWABHX) never contain 'Z' ch…
Browse files Browse the repository at this point in the history
…aracter in the randomly generated device name part because for modulo one does not need to substract 1 from strlen().

Signed-off-by: Hajo Noerenberg <hajo-github@noerenberg.de>
  • Loading branch information
hn authored and Christian Brauner committed Apr 10, 2019
1 parent 0630112 commit 13da0d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lxc/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -1982,9 +1982,9 @@ char *lxc_mkifname(char *template)
for (i = 0; i < strlen(name); i++) {
if (name[i] == 'X') {
#ifdef HAVE_RAND_R
name[i] = padchar[rand_r(&seed) % (strlen(padchar) - 1)];
name[i] = padchar[rand_r(&seed) % strlen(padchar)];
#else
name[i] = padchar[rand() % (strlen(padchar) - 1)];
name[i] = padchar[rand() % strlen(padchar)];
#endif
}
}
Expand Down

0 comments on commit 13da0d4

Please sign in to comment.