[OpenWrt-Devel] [PATCH procd 3/4] system: sysupgrade: rework firmware validation

2020-01-02 Thread Petr Štetiar
Fixes following deficiencies: * unhandled read() errors * everything bundled in one long function, which is hard to follow and reason about * JSON parser errors are being ignored, anything else then json_tokener_continue is fatal error * JSON parser errors are being output to stderr, thu

Re: [OpenWrt-Devel] [PATCH procd 3/4] system: sysupgrade: rework firmware validation

2020-01-04 Thread Hauke Mehrtens
On 1/3/20 1:46 AM, Petr Štetiar wrote: > Fixes following deficiencies: > > * unhandled read() errors > * everything bundled in one long function, which is hard to follow and >reason about > * JSON parser errors are being ignored, anything else then >json_tokener_continue is fatal error

Re: [OpenWrt-Devel] [PATCH procd 3/4] system: sysupgrade: rework firmware validation

2020-01-05 Thread Petr Štetiar
Hauke Mehrtens [2020-01-04 20:41:44]: Hi, thanks for the review! > Please annotate the function with: > __attribute__ ((format (printf, 2, 3))); Done. > > + va_start(va, fmt); > > + r = vsnprintf(buf+r, sizeof(buf)-r, fmt, va); > > Please check here for truncation: > > rv = vsnprintf(buf+

Re: [OpenWrt-Devel] [PATCH procd 3/4] system: sysupgrade: rework firmware validation

2020-01-05 Thread Hauke Mehrtens
On 1/5/20 11:40 AM, Petr Štetiar wrote: > Hauke Mehrtens [2020-01-04 20:41:44]: > > Hi, > > thanks for the review! > >> Please annotate the function with: >> __attribute__ ((format (printf, 2, 3))); > > Done. > >>> + va_start(va, fmt); >>> + r = vsnprintf(buf+r, sizeof(buf)-r, fmt, va); >

Re: [OpenWrt-Devel] [PATCH procd 3/4] system: sysupgrade: rework firmware validation

2020-01-05 Thread Petr Štetiar
Hauke Mehrtens [2020-01-04 20:41:44]: > > + vjson_error(err, "unhandled error"); > > In which case is this returned, aren't there specific error handlers in > call cases now and vjson_parse() would overwrite it again? It should be returned in unhandled cases, in case I've missed to handle some