Message ID | 1516885998-17854-1-git-send-email-sbabic@denx.de |
---|---|
State | Changes Requested |
Headers | show |
Series | swuforward: fix segmentation fault after changing dictionary | expand |
Hi Stefano, Am 25.01.2018 um 14:13 schrieb Stefano Babic: > Recent commit d406032411bbced04e425f3a11c7f7f259443de0 changed the way > to use dictionary. The function dict_get_list() returns a list if > properties is found and the returned pointer must be checked before using it. > > Missing check causes a segfault in swuforward when URLs are not parsed. > > Signed-off-by: Stefano Babic <sbabic@denx.de> > Reported-by: Alexandre April <aapril@kinova.ca> > --- > handlers/swuforward_handler.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/handlers/swuforward_handler.c b/handlers/swuforward_handler.c > index 8b0c17f..380f092 100644 > --- a/handlers/swuforward_handler.c > +++ b/handlers/swuforward_handler.c > @@ -307,6 +307,15 @@ static int install_remote_swu(struct img_type *img, > return -EINVAL; > } > > + /* > + * Check if there is a list of URLs where to forward > + * the SWU > + */ > + if (!dict_get_list(&img->properties, "url")) { > + ERROR("SWU to be forwarded, but not remote URLs found "); > + return -EINVAL; > + } > + > /* Reset list of connections */ > LIST_INIT(&priv.conns); > I would use a urls variable and reuse it in the LIST_FOREACH loop to make it clear that the return value of dict_get_list must be checked. Anyway thanks you for your fast fix. Regards Stefan
Hi Stefan, On 25/01/2018 19:43, Stefan Herbrechtsmeier wrote: > Hi Stefano, > > Am 25.01.2018 um 14:13 schrieb Stefano Babic: >> Recent commit d406032411bbced04e425f3a11c7f7f259443de0 changed the way >> to use dictionary. The function dict_get_list() returns a list if >> properties is found and the returned pointer must be checked before using it. >> >> Missing check causes a segfault in swuforward when URLs are not parsed. >> >> Signed-off-by: Stefano Babic <sbabic@denx.de> >> Reported-by: Alexandre April <aapril@kinova.ca> >> --- >> handlers/swuforward_handler.c | 9 +++++++++ >> 1 file changed, 9 insertions(+) >> >> diff --git a/handlers/swuforward_handler.c b/handlers/swuforward_handler.c >> index 8b0c17f..380f092 100644 >> --- a/handlers/swuforward_handler.c >> +++ b/handlers/swuforward_handler.c >> @@ -307,6 +307,15 @@ static int install_remote_swu(struct img_type *img, >> return -EINVAL; >> } >> >> + /* >> + * Check if there is a list of URLs where to forward >> + * the SWU >> + */ >> + if (!dict_get_list(&img->properties, "url")) { >> + ERROR("SWU to be forwarded, but not remote URLs found "); >> + return -EINVAL; >> + } >> + >> /* Reset list of connections */ >> LIST_INIT(&priv.conns); >> > I would use a urls variable and reuse it in the LIST_FOREACH loop to > make it clear that the return value of dict_get_list must be checked. > ok - I send a V2. > Anyway thanks you for your fast fix. > > Regards > Stefan > Regards, Stefano
diff --git a/handlers/swuforward_handler.c b/handlers/swuforward_handler.c index 8b0c17f..380f092 100644 --- a/handlers/swuforward_handler.c +++ b/handlers/swuforward_handler.c @@ -307,6 +307,15 @@ static int install_remote_swu(struct img_type *img, return -EINVAL; } + /* + * Check if there is a list of URLs where to forward + * the SWU + */ + if (!dict_get_list(&img->properties, "url")) { + ERROR("SWU to be forwarded, but not remote URLs found "); + return -EINVAL; + } + /* Reset list of connections */ LIST_INIT(&priv.conns);
Recent commit d406032411bbced04e425f3a11c7f7f259443de0 changed the way to use dictionary. The function dict_get_list() returns a list if properties is found and the returned pointer must be checked before using it. Missing check causes a segfault in swuforward when URLs are not parsed. Signed-off-by: Stefano Babic <sbabic@denx.de> Reported-by: Alexandre April <aapril@kinova.ca> --- handlers/swuforward_handler.c | 9 +++++++++ 1 file changed, 9 insertions(+)