Hi,

> [...]
> +
> +     blobmsg_for_each_attr(option, options, rem) {
> +             const char *prefix = "UPGRADE_OPT_";
> +             char *name = malloc(strlen(prefix) + 
> strlen(blobmsg_name(option)));
> +             char value[11];
> +             char *c;
> +             int tmp;
> +
> +             if (!name) {
> +                     continue;
> +             }
> +             sprintf(name, "%s%s", prefix, blobmsg_name(option));
> +             for (c = name + strlen(prefix); *c; c++) {

I'd propose some more sanity checking here:
                     if (isalnum(*c) || *c == '_') {
> +                     *c = toupper(*c);

                     }
                     else {
                        c = NULL;
                        break;
                     }
> +             }

                if (!c) {
                     fprintf(stderr, "Option \"%s\" contains invalid
characters\n", blobmsg_name(option));
                     free(name);
                     continue;
                }

> +
> +             switch (blobmsg_type(option)) {
> +             case BLOBMSG_TYPE_INT32:
> +                     tmp = blobmsg_get_u32(option);
> +                     break;
> +             case BLOBMSG_TYPE_INT16:
> +                     tmp = blobmsg_get_u16(option);
> +                     break;
> +             case BLOBMSG_TYPE_INT8:
> +                     tmp = blobmsg_get_u8(option);
> +                     break;
> +             default:
> +                     fprintf(stderr, "Option \"%s\" has unsupported type: 
> %d\n",
> +                             blobmsg_name(option), blobmsg_type(option));
> +                     free(name);
> +                     continue;
> +             }
> +             snprintf(value, sizeof(value), "%u", tmp);
> +
> +             setenv(name, value, 1);
> +
> +             free(name);
> +     }
> +
>       execvp(argv[0], argv);
>  
>       /* Cleanup on failure */
> diff --git a/sysupgrade.h b/sysupgrade.h
> index 8c09fc9..c84e494 100644
> --- a/sysupgrade.h
> +++ b/sysupgrade.h
> @@ -14,8 +14,10 @@
>  #ifndef __PROCD_SYSUPGRADE_H
>  #define __PROCD_SYSUPGRADE_H
>  
> +struct blob_attr;
>  
> -void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command);
> +void sysupgrade_exec_upgraded(const char *prefix, char *path, char *command,
> +                           struct blob_attr *options);
>  
>  
>  #endif
> 

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to