Makefile | 1 + noice.c | 10 +++++++--- diff --git a/Makefile b/Makefile index 922bf96d2e1f68115259f8c3e384e70ee550ea04..c2cdcad14242730ec0f2f685618f9fdc8659a618 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ #CPPFLAGS += -DDEBUG #CFLAGS += -g LDLIBS = -lncursesw +#LDLIBS += -lbsd BIN = noice all: $(BIN) diff --git a/noice.c b/noice.c index c69e85ee397329d47138e8078dcab2188239b231..656ec8f65fb41e7ada3a9d61152a1513241d9cfb 100644 --- a/noice.c +++ b/noice.c @@ -13,6 +13,10 @@ #include #include #include +#ifdef LINUX +#include +#endif + #ifdef DEBUG #define DEBUG_FD 8 #define DPRINTF_D(x) dprintf(DEBUG_FD, #x "=%d\n", x) @@ -280,13 +284,13 @@ DPRINTF_S(path); /* No text wrapping in cwd line */ cwd = malloc(COLS * sizeof(char)); - strncpy(cwd, path, COLS); + strlcpy(cwd, path, COLS * sizeof(char)); cwd[COLS - strlen(CWD) - 1] = '\0'; /* No text wrapping in entries */ tmpents = malloc(n * sizeof(*tmpents)); for (i = 0; i < n; i++) { - strncpy(tmpents[i].name, dents[i]->d_name, + strlcpy(tmpents[i].name, dents[i]->d_name, sizeof(tmpents[i].name)); tmpents[i].name[COLS - strlen(CURSR) - 1] = '\0'; } @@ -335,7 +339,7 @@ char *dir, *tmp; dir = dirname(path); tmp = malloc(strlen(dir) + 1); - strncpy(tmp, dir, strlen(dir) + 1); + strlcpy(tmp, dir, strlen(dir) + 1); free(path); path = tmp; goto out;