diff --git a/plugins/sudoers/iolog.c b/plugins/sudoers/iolog.c index 3a83d0781..976c49241 100644 --- a/plugins/sudoers/iolog.c +++ b/plugins/sudoers/iolog.c @@ -137,11 +137,12 @@ io_nextid(char *iolog_dir, char sessid[7]) { struct stat sb; char buf[32], *ep; - int fd, i, ch; + int fd, i; unsigned long id = 0; int len; ssize_t nread; char pathbuf[PATH_MAX]; + static const char b36char[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; /* * Create I/O log directory if it doesn't already exist. @@ -184,9 +185,8 @@ io_nextid(char *iolog_dir, char sessid[7]) * Note that that least significant digits go at the end of the string. */ for (i = 5; i >= 0; i--) { - ch = id % 36; + buf[i] = b36char[id % 36]; id /= 36; - buf[i] = ch < 10 ? ch + '0' : ch - 10 + 'A'; } buf[6] = '\n';