Skip to content
Snippets Groups Projects
Select Git revision
  • 15a80aaffdba9ed8bd6f97cacf6120de838946eb
  • v2018.2.x default
  • experimental
  • master
  • v2021.1.2-ffs
  • v2021.1.1-ffs
  • nrb/gluon-master-cpe510
  • v2021.1-ffs
  • v2020.2.3-ffs
  • nrbffs/fastd-remove-delay
  • v2020.2.2-ffs
  • v2020.2.1-ffs
  • v2020.2-ffs
  • v2020.2.x
  • v2020.1.3-ffs
  • v2020.1.1-ffs
  • v2020.1-ffs
  • v2019.1.2-ffs
  • v2019.1.1-ffs
  • nrb/test-radv-filter
  • v2019.1-ffs
  • nrbffs/netgear-ex6120
  • v2021.1.2-ffs0.2
  • v2021.1.2-ffs0.1
  • v2021.1.1-ffs0.4
  • v2021.1.1-ffs0.3
  • v2021.1.1-ffs0.2
  • v2021.1.1-ffs0.1
  • v2021.1-ffs0.1
  • v2020.2.3-ffs0.3
  • v2020.2.3-ffs0.2
  • v2020.2.3-ffs0.1
  • v2020.2.2-ffs0.1
  • v2020.2.1-ffs0.1
  • v2020.2-ffs0.1
  • v2020.2
  • v2020.2.x-ffs0.1
  • v2020.1.3-ffs0.1
  • v2020.1.1-ffs0.1
  • v2020.1-ffs0.1
  • v2019.1.2-ffs0.1
  • v2019.1.1-ffs0.1
42 results

0004-luci-lib-jsonc-Ignore-non-string-or-number-keys-in-tables.patch

Blame
  • Forked from firmware / FFS Gluon
    4149 commits behind the upstream repository.
    user avatar
    Jan-Philipp Litza authored
    Apart from replacing a patch for the former by two patches for latter,
    this involved minimal adaptations of the lua scripts in the following
    packages:
    
    * gluon-announce
    * gluon-announced
    * gluon-mesh-batman-adv-core
    * gluon-status-page
    15a80aaf
    History
    0004-luci-lib-jsonc-Ignore-non-string-or-number-keys-in-tables.patch 1.05 KiB
    From: Jan-Philipp Litza <janphilipp@litza.de>
    Date: Sun, 30 Aug 2015 15:42:52 +0200
    Subject: luci-lib-jsonc: Ignore non-string-or-number keys in tables
    
    Previously, the following caused a segmentation fault:
    
        json.stringify({[{}] = true})
    
    This was caused by lua_tostring() returning NULL for anything but
    strings and numbers, letting json_object_object_add crash.
    
    This patch makes jsonc ignore all keys which have no string
    representation altogether.
    
    Signed-off-by: Jan-Philipp Litza <janphilipp@litza.de>
    
    diff --git a/libs/luci-lib-jsonc/src/jsonc.c b/libs/luci-lib-jsonc/src/jsonc.c
    index 49cb21f..827fde8 100644
    --- a/libs/luci-lib-jsonc/src/jsonc.c
    +++ b/libs/luci-lib-jsonc/src/jsonc.c
    @@ -286,8 +286,9 @@ static struct json_object * _lua_to_json(lua_State *L, int index)
     			lua_pushvalue(L, -2);
     			key = lua_tostring(L, -1);
     
    -			json_object_object_add(obj, key,
    -								   _lua_to_json(L, lua_gettop(L) - 1));
    +			if (key)
    +				json_object_object_add(obj, key,
    +				                       _lua_to_json(L, lua_gettop(L) - 1));
     
     			lua_pop(L, 2);
     		}