aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-03-01 17:25:49 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-03-01 17:25:49 +0530
commit1224270104e2a2058998e1e2b71b32161e1d41d5 (patch)
treebdff5f1c1b4af3d1901e80ab1ac0a1a6e68e8ca9 /src
parentad9f834b640832a1f64e4901ade3845ca0971df7 (diff)
downloadnnn-1224270104e2a2058998e1e2b71b32161e1d41d5.tar.gz
Drop path validation
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/nnn.c b/src/nnn.c
index 63297e1..98069fb 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2918,7 +2918,7 @@ static bool parsekvpair(kv **arr, char **envcpy, const uchar id, ushort *items)
if (!maxitems)
return FALSE;
- *arr = calloc(maxitems, sizeof(kv));
+ *arr = malloc(maxitems * sizeof(kv));
if (!arr) {
xerror();
return FALSE;
@@ -2966,9 +2966,10 @@ static bool parsekvpair(kv **arr, char **envcpy, const uchar id, ushort *items)
if (kvarr[i - 1].val && *kvarr[i - 1].val == '\0')
return FALSE;
- for (i = 0; i < maxitems && kvarr[i].key; ++i)
- if (strlen(kvarr[i].val) >= PATH_MAX)
- return FALSE;
+ /* Redundant check so far, all paths will get evaluated and fail */
+ //for (i = 0; i < maxitems && kvarr[i].key; ++i)
+ // if (strlen(kvarr[i].val) >= PATH_MAX)
+ // return FALSE;
*items = maxitems;
return TRUE;
@@ -2980,7 +2981,7 @@ static bool parsekvpair(kv **arr, char **envcpy, const uchar id, ushort *items)
* NULL is returned in case of no match, path resolution failure etc.
* buf would be modified, so check return value before access
*/
-static char *get_kv_val(kv *kvarr, char *buf, int key, uchar max, bool path)
+static char *get_kv_val(kv *kvarr, char *buf, int key, uchar max, bool bookmark)
{
int r = 0;
@@ -2989,7 +2990,8 @@ static char *get_kv_val(kv *kvarr, char *buf, int key, uchar max, bool path)
for (; kvarr[r].key && r < max; ++r) {
if (kvarr[r].key == key) {
- if (!path)
+ /* Do not allocate new memory for plugin */
+ if (!bookmark)
return kvarr[r].val;
if (kvarr[r].val[0] == '~') {