net: lib: http_server: Verify fs_read result for filesystem resources
Verify the result of the fs_read() operation when handling filesystem resources, and abort processing the resource in case of errors. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
95333705e5
commit
df79f10513
2 changed files with 9 additions and 0 deletions
|
@ -450,6 +450,11 @@ int handle_http1_static_fs_resource(struct http_resource_detail_static_fs *stati
|
|||
remaining = file_size;
|
||||
while (remaining > 0) {
|
||||
len = fs_read(&file, http_response, sizeof(http_response));
|
||||
if (len < 0) {
|
||||
LOG_ERR("Filesystem read error (%d)", len);
|
||||
goto close;
|
||||
}
|
||||
|
||||
ret = http_server_sendall(client, http_response, len);
|
||||
if (ret < 0) {
|
||||
goto close;
|
||||
|
|
|
@ -470,6 +470,10 @@ static int handle_http2_static_fs_resource(struct http_resource_detail_static_fs
|
|||
remaining = client->data_len;
|
||||
while (remaining > 0) {
|
||||
len = fs_read(&file, tmp, sizeof(tmp));
|
||||
if (len < 0) {
|
||||
LOG_ERR("Filesystem read error (%d)", len);
|
||||
goto out;
|
||||
}
|
||||
|
||||
remaining -= len;
|
||||
ret = send_data_frame(client, tmp, len, frame->stream_identifier,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue