mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 20:01:27 +00:00
Limit filter length to NAME_MAX from LINE_MAX
This commit is contained in:
parent
959db96f99
commit
f2387898f3
29
nnn.c
29
nnn.c
|
@ -170,6 +170,7 @@ disabledbg()
|
||||||
#define clearprompt() printmsg("")
|
#define clearprompt() printmsg("")
|
||||||
#define printwarn() printmsg(strerror(errno))
|
#define printwarn() printmsg(strerror(errno))
|
||||||
#define istopdir(path) (path[1] == '\0' && path[0] == '/')
|
#define istopdir(path) (path[1] == '\0' && path[0] == '/')
|
||||||
|
#define copyfilter() xstrlcpy(fltr, ifilter, NAME_MAX)
|
||||||
#define settimeout() timeout(1000)
|
#define settimeout() timeout(1000)
|
||||||
#define cleartimeout() timeout(-1)
|
#define cleartimeout() timeout(-1)
|
||||||
#define errexit() printerr(__LINE__)
|
#define errexit() printerr(__LINE__)
|
||||||
|
@ -748,8 +749,8 @@ setfilter(regex_t *regex, char *filter)
|
||||||
r = regcomp(regex, filter, REG_NOSUB | REG_EXTENDED | REG_ICASE);
|
r = regcomp(regex, filter, REG_NOSUB | REG_EXTENDED | REG_ICASE);
|
||||||
if (r != 0 && filter && filter[0] != '\0') {
|
if (r != 0 && filter && filter[0] != '\0') {
|
||||||
len = COLS;
|
len = COLS;
|
||||||
if (len > LINE_MAX)
|
if (len > NAME_MAX)
|
||||||
len = LINE_MAX;
|
len = NAME_MAX;
|
||||||
regerror(r, regex, g_buf, len);
|
regerror(r, regex, g_buf, len);
|
||||||
printmsg(g_buf);
|
printmsg(g_buf);
|
||||||
}
|
}
|
||||||
|
@ -1093,8 +1094,8 @@ readinput(void)
|
||||||
cleartimeout();
|
cleartimeout();
|
||||||
echo();
|
echo();
|
||||||
curs_set(TRUE);
|
curs_set(TRUE);
|
||||||
memset(g_buf, 0, LINE_MAX);
|
memset(g_buf, 0, NAME_MAX + 1);
|
||||||
wgetnstr(stdscr, g_buf, LINE_MAX - 1);
|
wgetnstr(stdscr, g_buf, NAME_MAX);
|
||||||
noecho();
|
noecho();
|
||||||
curs_set(FALSE);
|
curs_set(FALSE);
|
||||||
settimeout();
|
settimeout();
|
||||||
|
@ -2140,7 +2141,7 @@ static void
|
||||||
browse(char *ipath, char *ifilter)
|
browse(char *ipath, char *ifilter)
|
||||||
{
|
{
|
||||||
static char path[PATH_MAX], oldpath[PATH_MAX], newpath[PATH_MAX], lastdir[PATH_MAX], mark[PATH_MAX];
|
static char path[PATH_MAX], oldpath[PATH_MAX], newpath[PATH_MAX], lastdir[PATH_MAX], mark[PATH_MAX];
|
||||||
static char fltr[LINE_MAX];
|
static char fltr[NAME_MAX + 1];
|
||||||
char *dir, *tmp, *run = NULL, *env = NULL;
|
char *dir, *tmp, *run = NULL, *env = NULL;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
int r, fd, presel;
|
int r, fd, presel;
|
||||||
|
@ -2148,7 +2149,7 @@ browse(char *ipath, char *ifilter)
|
||||||
bool dir_changed = FALSE;
|
bool dir_changed = FALSE;
|
||||||
|
|
||||||
xstrlcpy(path, ipath, PATH_MAX);
|
xstrlcpy(path, ipath, PATH_MAX);
|
||||||
xstrlcpy(fltr, ifilter, LINE_MAX);
|
copyfilter();
|
||||||
oldpath[0] = newpath[0] = lastdir[0] = mark[0] = '\0';
|
oldpath[0] = newpath[0] = lastdir[0] = mark[0] = '\0';
|
||||||
|
|
||||||
if (cfg.filtermode)
|
if (cfg.filtermode)
|
||||||
|
@ -2228,7 +2229,7 @@ nochange:
|
||||||
|
|
||||||
xstrlcpy(path, dir, PATH_MAX);
|
xstrlcpy(path, dir, PATH_MAX);
|
||||||
/* Reset filter */
|
/* Reset filter */
|
||||||
xstrlcpy(fltr, ifilter, LINE_MAX);
|
copyfilter();
|
||||||
if (cfg.filtermode)
|
if (cfg.filtermode)
|
||||||
presel = FILTER;
|
presel = FILTER;
|
||||||
goto begin;
|
goto begin;
|
||||||
|
@ -2268,7 +2269,7 @@ nochange:
|
||||||
xstrlcpy(path, newpath, PATH_MAX);
|
xstrlcpy(path, newpath, PATH_MAX);
|
||||||
oldpath[0] = '\0';
|
oldpath[0] = '\0';
|
||||||
/* Reset filter */
|
/* Reset filter */
|
||||||
xstrlcpy(fltr, ifilter, LINE_MAX);
|
copyfilter();
|
||||||
if (cfg.filtermode)
|
if (cfg.filtermode)
|
||||||
presel = FILTER;
|
presel = FILTER;
|
||||||
goto begin;
|
goto begin;
|
||||||
|
@ -2463,7 +2464,7 @@ nochange:
|
||||||
xstrlcpy(path, newpath, PATH_MAX);
|
xstrlcpy(path, newpath, PATH_MAX);
|
||||||
|
|
||||||
/* Reset filter */
|
/* Reset filter */
|
||||||
xstrlcpy(fltr, ifilter, LINE_MAX);
|
copyfilter();
|
||||||
DPRINTF_S(path);
|
DPRINTF_S(path);
|
||||||
if (cfg.filtermode)
|
if (cfg.filtermode)
|
||||||
presel = FILTER;
|
presel = FILTER;
|
||||||
|
@ -2494,7 +2495,7 @@ nochange:
|
||||||
xstrlcpy(path, dir, PATH_MAX);
|
xstrlcpy(path, dir, PATH_MAX);
|
||||||
oldpath[0] = '\0';
|
oldpath[0] = '\0';
|
||||||
/* Reset filter */
|
/* Reset filter */
|
||||||
xstrlcpy(fltr, ifilter, LINE_MAX);
|
copyfilter();
|
||||||
DPRINTF_S(path);
|
DPRINTF_S(path);
|
||||||
if (cfg.filtermode)
|
if (cfg.filtermode)
|
||||||
presel = FILTER;
|
presel = FILTER;
|
||||||
|
@ -2523,7 +2524,7 @@ nochange:
|
||||||
xstrlcpy(path, newpath, PATH_MAX);
|
xstrlcpy(path, newpath, PATH_MAX);
|
||||||
oldpath[0] = '\0';
|
oldpath[0] = '\0';
|
||||||
/* Reset filter */
|
/* Reset filter */
|
||||||
xstrlcpy(fltr, ifilter, LINE_MAX);
|
copyfilter();
|
||||||
DPRINTF_S(path);
|
DPRINTF_S(path);
|
||||||
if (cfg.filtermode)
|
if (cfg.filtermode)
|
||||||
presel = FILTER;
|
presel = FILTER;
|
||||||
|
@ -2556,7 +2557,7 @@ nochange:
|
||||||
xstrlcpy(path, newpath, PATH_MAX);
|
xstrlcpy(path, newpath, PATH_MAX);
|
||||||
|
|
||||||
/* Reset filter */
|
/* Reset filter */
|
||||||
xstrlcpy(fltr, ifilter, LINE_MAX);
|
copyfilter();
|
||||||
DPRINTF_S(path);
|
DPRINTF_S(path);
|
||||||
|
|
||||||
if (cfg.filtermode)
|
if (cfg.filtermode)
|
||||||
|
@ -2568,7 +2569,7 @@ nochange:
|
||||||
goto nochange;
|
goto nochange;
|
||||||
case SEL_FLTR:
|
case SEL_FLTR:
|
||||||
presel = filterentries(path);
|
presel = filterentries(path);
|
||||||
xstrlcpy(fltr, ifilter, LINE_MAX);
|
copyfilter();
|
||||||
DPRINTF_S(fltr);
|
DPRINTF_S(fltr);
|
||||||
/* Save current */
|
/* Save current */
|
||||||
if (ndents > 0)
|
if (ndents > 0)
|
||||||
|
@ -2587,7 +2588,7 @@ nochange:
|
||||||
case SEL_TOGGLEDOT:
|
case SEL_TOGGLEDOT:
|
||||||
cfg.showhidden ^= 1;
|
cfg.showhidden ^= 1;
|
||||||
initfilter(cfg.showhidden, &ifilter);
|
initfilter(cfg.showhidden, &ifilter);
|
||||||
xstrlcpy(fltr, ifilter, LINE_MAX);
|
copyfilter();
|
||||||
goto begin;
|
goto begin;
|
||||||
case SEL_DETAIL:
|
case SEL_DETAIL:
|
||||||
cfg.showdetail ^= 1;
|
cfg.showdetail ^= 1;
|
||||||
|
|
Loading…
Reference in a new issue