libubox: replace strtok with _r version.
authorRosen Penev <rosenp@gmail.com>
Thu, 22 Dec 2016 19:53:25 +0000 (11:53 -0800)
committerFelix Fietkau <nbd@nbd.name>
Sat, 24 Dec 2016 10:03:29 +0000 (11:03 +0100)
_r is re-entrant. Also happens to silence a cppcheck warning.

Signed-off by: Rosen Penev <rosenp@gmail.com>

ulog.c

diff --git a/ulog.c b/ulog.c
index 296605dde876f116217c228ef45a6ed4e77e61f2..b7300e720d21012ca60f96490cb24d91abd3efc5 100644 (file)
--- a/ulog.c
+++ b/ulog.c
@@ -35,12 +35,13 @@ static const char *ulog_default_ident(void)
        FILE *self;
        static char line[64];
        char *p = NULL;
+       char *sbuf;
 
        if ((self = fopen("/proc/self/status", "r")) != NULL) {
                while (fgets(line, sizeof(line), self)) {
                        if (!strncmp(line, "Name:", 5)) {
-                               strtok(line, "\t\n");
-                               p = strtok(NULL, "\t\n");
+                               strtok_r(line, "\t\n", &sbuf);
+                               p = strtok_r(NULL, "\t\n", &sbuf);
                                break;
                        }
                }