Message ID | 20201214220545.29488-1-bage@linutronix.de |
---|---|
State | Accepted |
Headers | show |
Series | swuforward-ws.c: Prevent segfault in TEXTRANGE_TO_STR | expand |
Hi Bastian, On 14.12.20 23:05, bage@linutronix.de wrote: > From: Bastian Germann <bage@linutronix.de> > > TEXTRANGE_TO_STR is called with uri.portText which might contain > {NULL,NULL} if there is no port information in a swuforward URL. > In that case, evaluate to NULL instead of calling substring. > > Signed-off-by: Bastian Germann <bage@linutronix.de> > --- > handlers/swuforward-ws.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/handlers/swuforward-ws.c b/handlers/swuforward-ws.c > index c2dbb5e..28ebba7 100644 > --- a/handlers/swuforward-ws.c > +++ b/handlers/swuforward-ws.c > @@ -33,7 +33,7 @@ struct wsconn { > struct curlconn *conn; /* Back pointer to main structure */ > }; > > -#define TEXTRANGE_TO_STR(f) (substring(f.first, 0, f.afterLast - f.first)) > +#define TEXTRANGE_TO_STR(f) (f.first == NULL ? NULL : substring(f.first, 0, f.afterLast - f.first)) Absolutely right, thanks for the fix ! > > static int callback_ws_swupdate(struct lws *wsi, enum lws_callback_reasons reason, > void *user, void *in, size_t len) > Acked-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
diff --git a/handlers/swuforward-ws.c b/handlers/swuforward-ws.c index c2dbb5e..28ebba7 100644 --- a/handlers/swuforward-ws.c +++ b/handlers/swuforward-ws.c @@ -33,7 +33,7 @@ struct wsconn { struct curlconn *conn; /* Back pointer to main structure */ }; -#define TEXTRANGE_TO_STR(f) (substring(f.first, 0, f.afterLast - f.first)) +#define TEXTRANGE_TO_STR(f) (f.first == NULL ? NULL : substring(f.first, 0, f.afterLast - f.first)) static int callback_ws_swupdate(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len)