فهرست منبع

ncd: modules: be aware of strings with null bytes

ambrop7 14 سال پیش
والد
کامیت
3f96e70617
49فایلهای تغییر یافته به همراه129 افزوده شده و 97 حذف شده
  1. 1 1
      ncd/modules/alias.c
  2. 1 1
      ncd/modules/arithmetic.c
  3. 1 1
      ncd/modules/call.c
  4. 1 1
      ncd/modules/choose.c
  5. 6 4
      ncd/modules/concat.c
  6. 6 4
      ncd/modules/concatv.c
  7. 2 2
      ncd/modules/daemon.c
  8. 2 2
      ncd/modules/depend.c
  9. 2 2
      ncd/modules/dynamic_depend.c
  10. 1 1
      ncd/modules/exit.c
  11. 1 1
      ncd/modules/foreach.c
  12. 1 1
      ncd/modules/from_string.c
  13. 1 1
      ncd/modules/if.c
  14. 3 3
      ncd/modules/imperative.c
  15. 1 1
      ncd/modules/index.c
  16. 1 1
      ncd/modules/ip_in_network.c
  17. 3 3
      ncd/modules/list.c
  18. 2 2
      ncd/modules/logical.c
  19. 2 2
      ncd/modules/multidepend.c
  20. 3 3
      ncd/modules/net_backend_badvpn.c
  21. 1 1
      ncd/modules/net_backend_rfkill.c
  22. 1 1
      ncd/modules/net_backend_waitdevice.c
  23. 1 1
      ncd/modules/net_backend_waitlink.c
  24. 3 3
      ncd/modules/net_backend_wpa_supplicant.c
  25. 1 1
      ncd/modules/net_dns.c
  26. 5 5
      ncd/modules/net_iptables.c
  27. 1 1
      ncd/modules/net_ipv4_addr.c
  28. 1 1
      ncd/modules/net_ipv4_arp_probe.c
  29. 3 3
      ncd/modules/net_ipv4_dhcp.c
  30. 2 2
      ncd/modules/net_ipv4_route.c
  31. 1 1
      ncd/modules/net_ipv6_wait_dynamic_addr.c
  32. 1 1
      ncd/modules/net_up.c
  33. 1 1
      ncd/modules/ondemand.c
  34. 6 1
      ncd/modules/parse.c
  35. 14 1
      ncd/modules/print.c
  36. 2 2
      ncd/modules/process_manager.c
  37. 7 2
      ncd/modules/regex_match.c
  38. 2 2
      ncd/modules/run.c
  39. 3 3
      ncd/modules/runonce.c
  40. 1 1
      ncd/modules/sleep.c
  41. 1 1
      ncd/modules/spawn.c
  42. 1 1
      ncd/modules/strcmp.c
  43. 1 1
      ncd/modules/sys_evdev.c
  44. 4 4
      ncd/modules/sys_request_client.c
  45. 4 4
      ncd/modules/sys_request_server.c
  46. 1 1
      ncd/modules/sys_watch_directory.c
  47. 1 1
      ncd/modules/sys_watch_input.c
  48. 2 3
      ncd/modules/try.c
  49. 16 10
      ncd/modules/value.c

+ 1 - 1
ncd/modules/alias.c

@@ -131,7 +131,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(target_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(target_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/arithmetic.c

@@ -183,7 +183,7 @@ static void new_templ (NCDModuleInst *i, compute_func cfunc)
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(n1_arg) != NCDVALUE_STRING || NCDValue_Type(n2_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(n1_arg) || !NCDValue_IsStringNoNulls(n2_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/call.c

@@ -212,7 +212,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(template_name_arg) != NCDVALUE_STRING || NCDValue_Type(args_arg) != NCDVALUE_LIST) {
+    if (!NCDValue_IsStringNoNulls(template_name_arg) || NCDValue_Type(args_arg) != NCDVALUE_LIST) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/choose.c

@@ -103,7 +103,7 @@ static void func_new (NCDModuleInst *i)
         }
         
         // update result
-        if (!o->result && !strcmp(NCDValue_StringValue(c_cond), "true")) {
+        if (!o->result && NCDValue_StringEquals(c_cond, "true")) {
             o->result = c_result;
         }
     }

+ 6 - 4
ncd/modules/concat.c

@@ -46,7 +46,8 @@
 
 struct instance {
     NCDModuleInst *i;
-    char *string;
+    uint8_t *string;
+    size_t len;
 };
 
 static void func_new (NCDModuleInst *i)
@@ -77,7 +78,7 @@ static void func_new (NCDModuleInst *i)
             goto fail2;
         }
         
-        if (!ExpString_Append(&s, NCDValue_StringValue(arg))) {
+        if (!ExpString_AppendBinary(&s, (const uint8_t *)NCDValue_StringValue(arg), NCDValue_StringLength(arg))) {
             ModuleLog(i, BLOG_ERROR, "ExpString_Append failed");
             goto fail2;
         }
@@ -86,7 +87,8 @@ static void func_new (NCDModuleInst *i)
     }
     
     // set string
-    o->string = ExpString_Get(&s);
+    o->string = (uint8_t *)ExpString_Get(&s);
+    o->len = ExpString_Length(&s);
     
     // signal up
     NCDModuleInst_Backend_Up(o->i);
@@ -121,7 +123,7 @@ static int func_getvar (void *vo, const char *name, NCDValue *out)
     struct instance *o = vo;
     
     if (!strcmp(name, "")) {
-        if (!NCDValue_InitString(out, o->string)) {
+        if (!NCDValue_InitStringBin(out, o->string, o->len)) {
             ModuleLog(o->i, BLOG_ERROR, "NCDValue_InitCopy failed");
             return 0;
         }

+ 6 - 4
ncd/modules/concatv.c

@@ -46,7 +46,8 @@
 
 struct instance {
     NCDModuleInst *i;
-    char *string;
+    uint8_t *string;
+    size_t len;
 };
 
 static void func_new (NCDModuleInst *i)
@@ -88,7 +89,7 @@ static void func_new (NCDModuleInst *i)
             goto fail2;
         }
         
-        if (!ExpString_Append(&s, NCDValue_StringValue(arg))) {
+        if (!ExpString_AppendBinary(&s, (const uint8_t *)NCDValue_StringValue(arg), NCDValue_StringLength(arg))) {
             ModuleLog(i, BLOG_ERROR, "ExpString_Append failed");
             goto fail2;
         }
@@ -97,7 +98,8 @@ static void func_new (NCDModuleInst *i)
     }
     
     // set string
-    o->string = ExpString_Get(&s);
+    o->string = (uint8_t *)ExpString_Get(&s);
+    o->len = ExpString_Length(&s);
     
     // signal up
     NCDModuleInst_Backend_Up(o->i);
@@ -132,7 +134,7 @@ static int func_getvar (void *vo, const char *name, NCDValue *out)
     struct instance *o = vo;
     
     if (!strcmp(name, "")) {
-        if (!NCDValue_InitString(out, o->string)) {
+        if (!NCDValue_InitStringBin(out, o->string, o->len)) {
             ModuleLog(o->i, BLOG_ERROR, "NCDValue_InitCopy failed");
             return 0;
         }

+ 2 - 2
ncd/modules/daemon.c

@@ -86,7 +86,7 @@ static int build_cmdline (NCDModuleInst *i, NCDValue *cmd_arg, char **exec, CmdL
         ModuleLog(i, BLOG_ERROR, "missing executable name");
         goto fail0;
     }
-    if (NCDValue_Type(exec_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(exec_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail0;
     }
@@ -110,7 +110,7 @@ static int build_cmdline (NCDModuleInst *i, NCDValue *cmd_arg, char **exec, CmdL
     // add additional arguments
     NCDValue *arg = exec_arg;
     while (arg = NCDValue_ListNext(cmd_arg, arg)) {
-        if (NCDValue_Type(arg) != NCDVALUE_STRING) {
+        if (!NCDValue_IsStringNoNulls(arg)) {
             ModuleLog(i, BLOG_ERROR, "wrong type");
             goto fail2;
         }

+ 2 - 2
ncd/modules/depend.c

@@ -184,7 +184,7 @@ static void provide_func_new_templ (NCDModuleInst *i, int event)
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(name_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(name_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }
@@ -317,7 +317,7 @@ static void depend_func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(name_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(name_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 2 - 2
ncd/modules/dynamic_depend.c

@@ -292,7 +292,7 @@ static void provide_func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(name_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(name_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail1;
     }
@@ -402,7 +402,7 @@ static void depend_func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(name_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(name_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/exit.c

@@ -54,7 +54,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
-    if (NCDValue_Type(exit_code_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(exit_code_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail0;
     }

+ 1 - 1
ncd/modules/foreach.c

@@ -412,7 +412,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(arg_list) != NCDVALUE_LIST || NCDValue_Type(arg_template) != NCDVALUE_STRING ||
+    if (NCDValue_Type(arg_list) != NCDVALUE_LIST || !NCDValue_IsStringNoNulls(arg_template) ||
         NCDValue_Type(arg_args) != NCDVALUE_LIST
     ) {
         ModuleLog(i, BLOG_ERROR, "wrong type");

+ 1 - 1
ncd/modules/from_string.c

@@ -66,7 +66,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(str_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(str_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/if.c

@@ -77,7 +77,7 @@ static void new_templ (NCDModuleInst *i, int not)
     }
     
     // compute logical value of argument
-    int c = !strcmp(NCDValue_StringValue(arg), "true");
+    int c = NCDValue_StringEquals(arg, "true");
     
     // signal up if needed
     if ((not && !c) || (!not && c)) {

+ 3 - 3
ncd/modules/imperative.c

@@ -255,9 +255,9 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(init_template_arg) != NCDVALUE_STRING || NCDValue_Type(init_args) != NCDVALUE_LIST ||
-        NCDValue_Type(deinit_template_arg) != NCDVALUE_STRING || NCDValue_Type(o->deinit_args) != NCDVALUE_LIST ||
-        NCDValue_Type(deinit_timeout_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(init_template_arg) || NCDValue_Type(init_args) != NCDVALUE_LIST ||
+        !NCDValue_IsStringNoNulls(deinit_template_arg) || NCDValue_Type(o->deinit_args) != NCDVALUE_LIST ||
+        !NCDValue_IsStringNoNulls(deinit_timeout_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/index.c

@@ -91,7 +91,7 @@ static void func_new_from_value (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
-    if (NCDValue_Type(arg_value) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(arg_value)) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail0;
     }

+ 1 - 1
ncd/modules/ip_in_network.c

@@ -72,7 +72,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(arg_addr1) != NCDVALUE_STRING || NCDValue_Type(arg_addr2) != NCDVALUE_STRING || NCDValue_Type(arg_netprefix) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(arg_addr1) || !NCDValue_IsStringNoNulls(arg_addr2) || !NCDValue_IsStringNoNulls(arg_netprefix)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 3 - 3
ncd/modules/list.c

@@ -505,7 +505,7 @@ static void get_func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(index_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(index_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }
@@ -717,7 +717,7 @@ static void find_func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(start_pos_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(start_pos_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }
@@ -820,7 +820,7 @@ static void removeat_func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(remove_pos_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(remove_pos_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 2 - 2
ncd/modules/logical.c

@@ -82,7 +82,7 @@ static void func_new (NCDModuleInst *i, int not, int or)
             goto fail1;
         }
         
-        o->value = !!strcmp(NCDValue_StringValue(arg), "true");
+        o->value = !NCDValue_StringEquals(arg, "true");
     } else {
         o->value = (or ? 0 : 1);
         
@@ -93,7 +93,7 @@ static void func_new (NCDModuleInst *i, int not, int or)
                 goto fail1;
             }
             
-            int this_value = !strcmp(NCDValue_StringValue(arg), "true");
+            int this_value = NCDValue_StringEquals(arg, "true");
             if (or) {
                 o->value = o->value || this_value;
             } else {

+ 2 - 2
ncd/modules/multidepend.c

@@ -173,7 +173,7 @@ static void provide_func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(name_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(name_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }
@@ -286,7 +286,7 @@ static void depend_func_new (NCDModuleInst *i)
     // check names list
     NCDValue *e = NCDValue_ListFirst(o->names);
     while (e) {
-        if (NCDValue_Type(e) != NCDVALUE_STRING) {
+        if (!NCDValue_IsStringNoNulls(e)) {
             ModuleLog(o->i, BLOG_ERROR, "wrong type");
             goto fail1;
         }

+ 3 - 3
ncd/modules/net_backend_badvpn.c

@@ -169,8 +169,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(ifname_arg) != NCDVALUE_STRING || NCDValue_Type(user_arg) != NCDVALUE_STRING ||
-        NCDValue_Type(exec_arg) != NCDVALUE_STRING || NCDValue_Type(args_arg) != NCDVALUE_LIST) {
+    if (!NCDValue_IsStringNoNulls(ifname_arg) || !NCDValue_IsStringNoNulls(user_arg) ||
+        !NCDValue_IsStringNoNulls(exec_arg) || NCDValue_Type(args_arg) != NCDVALUE_LIST) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }
@@ -182,7 +182,7 @@ static void func_new (NCDModuleInst *i)
     // check arguments
     NCDValue *arg = NCDValue_ListFirst(o->args);
     while (arg) {
-        if (NCDValue_Type(arg) != NCDVALUE_STRING) {
+        if (!NCDValue_IsStringNoNulls(arg)) {
             ModuleLog(o->i, BLOG_ERROR, "wrong type");
             goto fail1;
         }

+ 1 - 1
ncd/modules/net_backend_rfkill.c

@@ -150,7 +150,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(type_arg) != NCDVALUE_STRING || NCDValue_Type(name_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(type_arg) || !NCDValue_IsStringNoNulls(name_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/net_backend_waitdevice.c

@@ -134,7 +134,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/net_backend_waitlink.c

@@ -93,7 +93,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 3 - 3
ncd/modules/net_backend_wpa_supplicant.c

@@ -218,7 +218,7 @@ int build_cmdline (struct instance *o, CmdLine *c)
     // append user arguments
     NCDValue *arg = NCDValue_ListFirst(o->args);
     while (arg) {
-        if (NCDValue_Type(arg) != NCDVALUE_STRING) {
+        if (!NCDValue_IsStringNoNulls(arg)) {
             ModuleLog(o->i, BLOG_ERROR, "wrong type");
             goto fail1;
         }
@@ -410,8 +410,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(ifname_arg) != NCDVALUE_STRING || NCDValue_Type(conf_arg) != NCDVALUE_STRING ||
-        NCDValue_Type(exec_arg) != NCDVALUE_STRING || NCDValue_Type(args_arg) != NCDVALUE_LIST) {
+    if (!NCDValue_IsStringNoNulls(ifname_arg) || !NCDValue_IsStringNoNulls(conf_arg)  ||
+        !NCDValue_IsStringNoNulls(exec_arg) || NCDValue_Type(args_arg) != NCDVALUE_LIST) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/net_dns.c

@@ -226,7 +226,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(servers_arg) != NCDVALUE_LIST || NCDValue_Type(priority_arg) != NCDVALUE_STRING) {
+    if (NCDValue_Type(servers_arg) != NCDVALUE_LIST || !NCDValue_IsStringNoNulls(priority_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 5 - 5
ncd/modules/net_iptables.c

@@ -141,7 +141,7 @@ static int build_append_cmdline (NCDModuleInst *i, int remove, char **exec, CmdL
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
-    if (NCDValue_Type(table_arg) != NCDVALUE_STRING || NCDValue_Type(chain_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(table_arg) || !NCDValue_IsStringNoNulls(chain_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail0;
     }
@@ -175,7 +175,7 @@ static int build_append_cmdline (NCDModuleInst *i, int remove, char **exec, CmdL
     // add additional arguments
     NCDValue *arg = NCDValue_ListNext(i->args, chain_arg);
     while (arg) {
-        if (NCDValue_Type(arg) != NCDVALUE_STRING) {
+        if (!NCDValue_IsStringNoNulls(arg)) {
             ModuleLog(i, BLOG_ERROR, "wrong type");
             goto fail2;
         }
@@ -215,8 +215,8 @@ static int build_policy_cmdline (NCDModuleInst *i, int remove, char **exec, CmdL
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
-    if (NCDValue_Type(table_arg) != NCDVALUE_STRING || NCDValue_Type(chain_arg) != NCDVALUE_STRING ||
-        NCDValue_Type(target_arg) != NCDVALUE_STRING || NCDValue_Type(revert_target_arg) != NCDVALUE_STRING
+    if (!NCDValue_IsStringNoNulls(table_arg) || !NCDValue_IsStringNoNulls(chain_arg) ||
+        !NCDValue_IsStringNoNulls(target_arg) || !NCDValue_IsStringNoNulls(revert_target_arg)
     ) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail0;
@@ -275,7 +275,7 @@ static int build_newchain_cmdline (NCDModuleInst *i, int remove, char **exec, Cm
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
-    if (NCDValue_Type(chain_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(chain_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail0;
     }

+ 1 - 1
ncd/modules/net_ipv4_addr.c

@@ -70,7 +70,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(ifname_arg) != NCDVALUE_STRING || NCDValue_Type(addr_arg) != NCDVALUE_STRING || NCDValue_Type(prefix_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(ifname_arg) || !NCDValue_IsStringNoNulls(addr_arg) || !NCDValue_IsStringNoNulls(prefix_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/net_ipv4_arp_probe.c

@@ -138,7 +138,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(arg_ifname) != NCDVALUE_STRING || NCDValue_Type(arg_addr) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(arg_ifname) || !NCDValue_IsStringNoNulls(arg_addr)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 3 - 3
ncd/modules/net_ipv4_dhcp.c

@@ -115,7 +115,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(ifname_arg) != NCDVALUE_STRING || (opts_arg && NCDValue_Type(opts_arg) != NCDVALUE_LIST)) {
+    if (!NCDValue_IsStringNoNulls(ifname_arg) || (opts_arg && NCDValue_Type(opts_arg) != NCDVALUE_LIST)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }
@@ -126,7 +126,7 @@ static void func_new (NCDModuleInst *i)
     // read options
     for (NCDValue *opt = (opts_arg ? NCDValue_ListFirst(opts_arg) : NULL); opt; opt = NCDValue_ListNext(opts_arg, opt)) {
         // read name
-        if (NCDValue_Type(opt) != NCDVALUE_STRING) {
+        if (!NCDValue_IsStringNoNulls(opt)) {
             ModuleLog(o->i, BLOG_ERROR, "wrong option name type");
             goto fail1;
         }
@@ -139,7 +139,7 @@ static void func_new (NCDModuleInst *i)
                 ModuleLog(o->i, BLOG_ERROR, "option value missing");
                 goto fail1;
             }
-            if (NCDValue_Type(val) != NCDVALUE_STRING) {
+            if (!NCDValue_IsStringNoNulls(val)) {
                 ModuleLog(o->i, BLOG_ERROR, "wrong option value type");
                 goto fail1;
             }

+ 2 - 2
ncd/modules/net_ipv4_route.c

@@ -85,8 +85,8 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(dest_arg) != NCDVALUE_STRING || NCDValue_Type(dest_prefix_arg) != NCDVALUE_STRING || NCDValue_Type(gateway_arg) != NCDVALUE_STRING ||
-        NCDValue_Type(metric_arg) != NCDVALUE_STRING || NCDValue_Type(ifname_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(dest_arg) || !NCDValue_IsStringNoNulls(dest_prefix_arg) || !NCDValue_IsStringNoNulls(gateway_arg) ||
+        !NCDValue_IsStringNoNulls(metric_arg) || !NCDValue_IsStringNoNulls(ifname_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/net_ipv6_wait_dynamic_addr.c

@@ -109,7 +109,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(ifname_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(ifname_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/net_up.c

@@ -68,7 +68,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(ifname_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(ifname_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/ondemand.c

@@ -236,7 +236,7 @@ static void ondemand_func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(arg_template_name) != NCDVALUE_STRING || NCDValue_Type(arg_args) != NCDVALUE_LIST) {
+    if (!NCDValue_IsStringNoNulls(arg_template_name) || NCDValue_Type(arg_args) != NCDVALUE_LIST) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 6 - 1
ncd/modules/parse.c

@@ -133,7 +133,12 @@ static void new_templ (NCDModuleInst *i, parse_func pfunc)
     }
     
     // parse
-    o->succeeded = pfunc(i, NCDValue_StringValue(str_arg), &o->value);
+    if (NCDValue_StringHasNulls(str_arg)) {
+        ModuleLog(o->i, BLOG_ERROR, "string has nulls");
+        o->succeeded = 0;
+    } else {
+        o->succeeded = pfunc(i, NCDValue_StringValue(str_arg), &o->value);
+    }
     
     // signal up
     NCDModuleInst_Backend_Up(i);

+ 14 - 1
ncd/modules/print.c

@@ -70,7 +70,20 @@ static void do_print (NCDModuleInst *i, int ln)
 {
     for (NCDValue *arg = NCDValue_ListFirst(i->args); arg; arg = NCDValue_ListNext(i->args, arg)) {
         ASSERT(NCDValue_Type(arg) == NCDVALUE_STRING)
-        printf("%s", NCDValue_StringValue(arg));
+        
+        const char *str = NCDValue_StringValue(arg);
+        size_t len = NCDValue_StringLength(arg);
+        size_t pos = 0;
+        
+        while (pos < len) {
+            ssize_t res = fwrite(str + pos, 1, len - pos, stdout);
+            if (res <= 0) {
+                break;
+            }
+            
+            pos += res;
+            len -= res;
+        }
     }
     
     if (ln) {

+ 2 - 2
ncd/modules/process_manager.c

@@ -476,7 +476,7 @@ static void start_func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
-    if (NCDValue_Type(name_arg) != NCDVALUE_STRING || NCDValue_Type(template_name_arg) != NCDVALUE_STRING ||
+    if (!NCDValue_IsStringNoNulls(name_arg) || !NCDValue_IsStringNoNulls(template_name_arg) ||
         NCDValue_Type(args_arg) != NCDVALUE_LIST) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail0;
@@ -527,7 +527,7 @@ static void stop_func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "wrong arity");
         goto fail0;
     }
-    if (NCDValue_Type(name_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(name_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail0;
     }

+ 7 - 2
ncd/modules/regex_match.c

@@ -79,7 +79,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(input_arg) != NCDVALUE_STRING || NCDValue_Type(regex_arg) != NCDVALUE_STRING) {
+    if (NCDValue_Type(input_arg) != NCDVALUE_STRING || !NCDValue_IsStringNoNulls(regex_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }
@@ -95,7 +95,12 @@ static void func_new (NCDModuleInst *i)
     }
     
     // execute match
-    o->succeeded = (regexec(&preg, o->input, MAX_MATCHES, o->matches, 0) == 0);
+    if (NCDValue_StringHasNulls(input_arg)) {
+        ModuleLog(o->i, BLOG_ERROR, "string has nulls");
+        o->succeeded = 0;
+    } else {
+        o->succeeded = (regexec(&preg, o->input, MAX_MATCHES, o->matches, 0) == 0);
+    }
     
     // free regex
     regfree(&preg);

+ 2 - 2
ncd/modules/run.c

@@ -81,7 +81,7 @@ static int build_cmdline (NCDModuleInst *i, int remove, char **exec, CmdLine *cl
     
     // read exec
     NCDValue *exec_arg = NCDValue_ListFirst(list);
-    if (NCDValue_Type(exec_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(exec_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail0;
     }
@@ -105,7 +105,7 @@ static int build_cmdline (NCDModuleInst *i, int remove, char **exec, CmdLine *cl
     // add additional arguments
     NCDValue *arg = exec_arg;
     while (arg = NCDValue_ListNext(list, arg)) {
-        if (NCDValue_Type(arg) != NCDVALUE_STRING) {
+        if (!NCDValue_IsStringNoNulls(arg)) {
             ModuleLog(i, BLOG_ERROR, "wrong type");
             goto fail2;
         }

+ 3 - 3
ncd/modules/runonce.c

@@ -85,7 +85,7 @@ static int build_cmdline (NCDModuleInst *i, NCDValue *cmd_arg, char **exec, CmdL
         ModuleLog(i, BLOG_ERROR, "missing executable name");
         goto fail0;
     }
-    if (NCDValue_Type(exec_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(exec_arg)) {
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail0;
     }
@@ -109,7 +109,7 @@ static int build_cmdline (NCDModuleInst *i, NCDValue *cmd_arg, char **exec, CmdL
     // add additional arguments
     NCDValue *arg = exec_arg;
     while (arg = NCDValue_ListNext(cmd_arg, arg)) {
-        if (NCDValue_Type(arg) != NCDVALUE_STRING) {
+        if (!NCDValue_IsStringNoNulls(arg)) {
             ModuleLog(i, BLOG_ERROR, "wrong type");
             goto fail2;
         }
@@ -192,7 +192,7 @@ static void func_new (NCDModuleInst *i)
     // read options
     for (NCDValue *opt = (opts_arg ? NCDValue_ListFirst(opts_arg) : NULL); opt; opt = NCDValue_ListNext(opts_arg, opt)) {
         // read name
-        if (NCDValue_Type(opt) != NCDVALUE_STRING) {
+        if (!NCDValue_IsStringNoNulls(opt)) {
             ModuleLog(o->i, BLOG_ERROR, "wrong option name type");
             goto fail1;
         }

+ 1 - 1
ncd/modules/sleep.c

@@ -88,7 +88,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(ms_start_arg) != NCDVALUE_STRING || NCDValue_Type(ms_stop_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(ms_start_arg) || !NCDValue_IsStringNoNulls(ms_stop_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/spawn.c

@@ -109,7 +109,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(template_name_arg) != NCDVALUE_STRING || NCDValue_Type(args_arg) != NCDVALUE_LIST) {
+    if (!NCDValue_IsStringNoNulls(template_name_arg) || NCDValue_Type(args_arg) != NCDVALUE_LIST) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/strcmp.c

@@ -101,7 +101,7 @@ static int func_getvar (void *vo, const char *name, NCDValue *out)
     struct instance *o = vo;
     
     if (!strcmp(name, "")) {
-        const char *v = (!strcmp(NCDValue_StringValue(o->arg1), NCDValue_StringValue(o->arg2)) ? "true" : "false");
+        const char *v = !NCDValue_Compare(o->arg1, o->arg2) ? "true" : "false";
         
         if (!NCDValue_InitString(out, v)) {
             ModuleLog(o->i, BLOG_ERROR, "NCDValue_InitString failed");

+ 1 - 1
ncd/modules/sys_evdev.c

@@ -160,7 +160,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(device_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(device_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 4 - 4
ncd/modules/sys_request_client.c

@@ -487,7 +487,7 @@ static int get_connect_addr (struct instance *o, NCDValue *connect_addr_arg, str
     }
     NCDValue *type_arg = NCDValue_ListFirst(connect_addr_arg);
     
-    if (NCDValue_Type(type_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(type_arg)) {
         goto bad;
     }
     const char *type = NCDValue_StringValue(type_arg);
@@ -498,7 +498,7 @@ static int get_connect_addr (struct instance *o, NCDValue *connect_addr_arg, str
             goto bad;
         }
         
-        if (NCDValue_Type(socket_path_arg) != NCDVALUE_STRING) {
+        if (!NCDValue_IsStringNoNulls(socket_path_arg)) {
             goto bad;
         }
         
@@ -511,7 +511,7 @@ static int get_connect_addr (struct instance *o, NCDValue *connect_addr_arg, str
             goto bad;
         }
         
-        if (NCDValue_Type(ip_address_arg) != NCDVALUE_STRING || NCDValue_Type(port_number_arg) != NCDVALUE_STRING) {
+        if (!NCDValue_IsStringNoNulls(ip_address_arg) || !NCDValue_IsStringNoNulls(port_number_arg)) {
             goto bad;
         }
         
@@ -637,7 +637,7 @@ static void request_func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(reply_handler_arg) != NCDVALUE_STRING || NCDValue_Type(finished_handler_arg) != NCDVALUE_STRING ||
+    if (!NCDValue_IsStringNoNulls(reply_handler_arg) || !NCDValue_IsStringNoNulls(finished_handler_arg) ||
         NCDValue_Type(args_arg) != NCDVALUE_LIST
     ) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");

+ 4 - 4
ncd/modules/sys_request_server.c

@@ -657,7 +657,7 @@ static int init_listen (struct instance *o, NCDValue *listen_addr_arg)
     }
     NCDValue *type_arg = NCDValue_ListFirst(listen_addr_arg);
     
-    if (NCDValue_Type(type_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(type_arg)) {
         goto bad;
     }
     const char *type = NCDValue_StringValue(type_arg);
@@ -670,7 +670,7 @@ static int init_listen (struct instance *o, NCDValue *listen_addr_arg)
             goto bad;
         }
         
-        if (NCDValue_Type(socket_path_arg) != NCDVALUE_STRING) {
+        if (!NCDValue_IsStringNoNulls(socket_path_arg)) {
             goto bad;
         }
         
@@ -696,7 +696,7 @@ static int init_listen (struct instance *o, NCDValue *listen_addr_arg)
             goto bad;
         }
         
-        if (NCDValue_Type(ip_address_arg) != NCDVALUE_STRING || NCDValue_Type(port_number_arg) != NCDVALUE_STRING) {
+        if (!NCDValue_IsStringNoNulls(ip_address_arg) || !NCDValue_IsStringNoNulls(port_number_arg)) {
             goto bad;
         }
         
@@ -749,7 +749,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(request_handler_template_arg) != NCDVALUE_STRING || NCDValue_Type(args_arg) != NCDVALUE_LIST) {
+    if (!NCDValue_IsStringNoNulls(request_handler_template_arg) || NCDValue_Type(args_arg) != NCDVALUE_LIST) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/sys_watch_directory.c

@@ -253,7 +253,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(dir_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(dir_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 1 - 1
ncd/modules/sys_watch_input.c

@@ -365,7 +365,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(devnode_type_arg) != NCDVALUE_STRING) {
+    if (!NCDValue_IsStringNoNulls(devnode_type_arg)) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }

+ 2 - 3
ncd/modules/try.c

@@ -174,7 +174,7 @@ static void func_new (NCDModuleInst *i)
         ModuleLog(o->i, BLOG_ERROR, "wrong arity");
         goto fail1;
     }
-    if (NCDValue_Type(template_name_arg) != NCDVALUE_STRING || NCDValue_Type(args_arg) != NCDVALUE_LIST) {
+    if (!NCDValue_IsStringNoNulls(template_name_arg) || NCDValue_Type(args_arg) != NCDVALUE_LIST) {
         ModuleLog(o->i, BLOG_ERROR, "wrong type");
         goto fail1;
     }
@@ -270,7 +270,6 @@ static void assert_func_new (NCDModuleInst *i)
         ModuleLog(i, BLOG_ERROR, "wrong type");
         goto fail1;
     }
-    char *cond = NCDValue_StringValue(cond_arg);
     
     // get instance
     struct instance *mo = i->method_user;
@@ -279,7 +278,7 @@ static void assert_func_new (NCDModuleInst *i)
     // signal up
     NCDModuleInst_Backend_Up(i);
     
-    if (strcmp(cond, "true")) {
+    if (!NCDValue_StringEquals(cond_arg, "true")) {
         // mark not succeeded
         mo->succeeded = 0;
         

+ 16 - 10
ncd/modules/value.c

@@ -104,6 +104,7 @@
 #include <string.h>
 #include <stddef.h>
 #include <limits.h>
+#include <stdint.h>
 
 #include <misc/offset.h>
 #include <misc/debug.h>
@@ -150,7 +151,8 @@ struct value {
     int type;
     union {
         struct {
-            char *string;
+            uint8_t *string;
+            size_t length;
         } string;
         struct {
             IndexedList list_contents_il;
@@ -165,7 +167,7 @@ static int ncdvalue_comparator (void *unused, void *vv1, void *vv2);
 static const char * get_type_str (int type);
 static void value_cleanup (struct value *v);
 static void value_delete (struct value *v);
-static struct value * value_init_string (NCDModuleInst *i, const char *str);
+static struct value * value_init_string (NCDModuleInst *i, const uint8_t *str, size_t len);
 static struct value * value_init_list (NCDModuleInst *i);
 static size_t value_list_len (struct value *v);
 static struct value * value_list_at (struct value *v, size_t index);
@@ -288,7 +290,7 @@ static void value_delete (struct value *v)
     free(v);
 }
 
-static struct value * value_init_string (NCDModuleInst *i, const char *str)
+static struct value * value_init_string (NCDModuleInst *i, const uint8_t *str, size_t len)
 {
     struct value *v = malloc(sizeof(*v));
     if (!v) {
@@ -300,11 +302,15 @@ static struct value * value_init_string (NCDModuleInst *i, const char *str)
     v->parent = NULL;
     v->type = NCDVALUE_STRING;
     
-    if (!(v->string.string = strdup(str))) {
-        ModuleLog(i, BLOG_ERROR, "strdup failed");
+    if (!(v->string.string = malloc(len))) {
+        ModuleLog(i, BLOG_ERROR, "malloc failed");
         goto fail1;
     }
     
+    memcpy(v->string.string, str, len);
+    
+    v->string.length = len;
+    
     return v;
     
 fail1:
@@ -488,7 +494,7 @@ static struct value * value_init_fromvalue (NCDModuleInst *i, NCDValue *value)
     
     switch (NCDValue_Type(value)) {
         case NCDVALUE_STRING: {
-            if (!(v = value_init_string(i, NCDValue_StringValue(value)))) {
+            if (!(v = value_init_string(i, (const uint8_t *)NCDValue_StringValue(value), NCDValue_StringLength(value)))) {
                 goto fail0;
             }
         } break;
@@ -554,7 +560,7 @@ static int value_to_value (NCDModuleInst *i, struct value *v, NCDValue *out_valu
 {
     switch (v->type) {
         case NCDVALUE_STRING: {
-            if (!(NCDValue_InitString(out_value, v->string.string))) {
+            if (!(NCDValue_InitStringBin(out_value, v->string.string, v->string.length))) {
                 ModuleLog(i, BLOG_ERROR, "NCDValue_InitString failed");
                 goto fail0;
             }
@@ -631,7 +637,7 @@ static struct value * value_get (NCDModuleInst *i, struct value *v, NCDValue *wh
             }
             
             uintmax_t index;
-            if (!parse_unsigned_integer(NCDValue_StringValue(where), &index)) {
+            if (NCDValue_StringHasNulls(where) || !parse_unsigned_integer(NCDValue_StringValue(where), &index)) {
                 if (!no_error) ModuleLog(i, BLOG_ERROR, "index is not a valid number (resolving into list)");
                 goto fail;
             }
@@ -703,7 +709,7 @@ static struct value * value_insert (NCDModuleInst *i, struct value *v, NCDValue
             }
             
             uintmax_t index;
-            if (!parse_unsigned_integer(NCDValue_StringValue(where), &index)) {
+            if (NCDValue_StringHasNulls(where) || !parse_unsigned_integer(NCDValue_StringValue(where), &index)) {
                 ModuleLog(i, BLOG_ERROR, "index is not a valid number (inserting into list)");
                 goto fail1;
             }
@@ -773,7 +779,7 @@ static int value_remove (NCDModuleInst *i, struct value *v, NCDValue *where)
             }
             
             uintmax_t index;
-            if (!parse_unsigned_integer(NCDValue_StringValue(where), &index)) {
+            if (NCDValue_StringHasNulls(where) || !parse_unsigned_integer(NCDValue_StringValue(where), &index)) {
                 ModuleLog(i, BLOG_ERROR, "index is not a valid number (removing from list)");
                 goto fail;
             }