uclient crash when trying to abort connection after getting HTTP headers

Rafał Miłecki rafal at milecki.pl
Tue May 25 05:30:00 PDT 2021


I'd like to abort uclient connection after getting HTTP error code in a
response header.

Example:
static void foo_header_done_cb(struct uclient *cl)
{
	if (cl->status_code != 200) {
		uclient_disconnect(cl);
		uclient_free(cl);
	}
}

The problem is that uclient_http_headers_complete() [1] after calling
"header_done" callback still uses the uclient struct. Freeing it results
in a crash. On the other hand calling uclient_disconnect() without
uclient_free() will result in memory leak.

Any hint, please?

[1] https://lxr.openwrt.org/source/uclient/uclient-http.c#L635

-- 
Rafał



More information about the openwrt-devel mailing list