diff options
| author | Andrew Clayton <ac@sigsegv.uk> | 2025-06-26 22:20:46 +0100 |
|---|---|---|
| committer | Andrew Clayton <a.clayton@nginx.com> | 2025-06-26 22:24:01 +0100 |
| commit | 0c5bb8a5e10657cec505729596c8b2f0c794cc8f (patch) | |
| tree | 1695c1ba5698c539795bf265f56f9b606dbced23 /src | |
| parent | 4eaecc5e8aa7bbaf9e58bf56560a8b1e67d0a8b7 (diff) | |
| download | nginx-no-short-read-checks.tar.gz nginx-no-short-read-checks.tar.bz2 | |
Remove short read checksno-short-read-checks
This removes a bunch of checks for cases where we _read_ less bytes than
asked for.
There are several reasons why we may _read_ less bytes including reading
data from a network file system.
This has proven to be an issue.
Closes: https://github.com/nginx/nginx/issues/265
Signed-off-by: Andrew Clayton <ac@sigsegv.uk>
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/ngx_conf_file.c | 8 | ||||
| -rw-r--r-- | src/core/ngx_output_chain.c | 7 | ||||
| -rw-r--r-- | src/event/ngx_event_openssl.c | 7 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_geo_module.c | 7 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_mp4_module.c | 7 | ||||
| -rw-r--r-- | src/http/ngx_http_file_cache.c | 7 | ||||
| -rw-r--r-- | src/http/v3/ngx_http_v3_module.c | 7 | ||||
| -rw-r--r-- | src/stream/ngx_stream_geo_module.c | 7 |
8 files changed, 0 insertions, 57 deletions
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index 197704b0f..cb566dac8 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -593,14 +593,6 @@ ngx_conf_read_token(ngx_conf_t *cf) return NGX_ERROR; } - if (n != size) { - ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - ngx_read_file_n " returned " - "only %z bytes instead of %z", - n, size); - return NGX_ERROR; - } - b->pos = b->start + len; b->last = b->pos + n; start = b->start; diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c index a46209c17..078326d56 100644 --- a/src/core/ngx_output_chain.c +++ b/src/core/ngx_output_chain.c @@ -623,13 +623,6 @@ ngx_output_chain_copy_buf(ngx_output_chain_ctx_t *ctx) return (ngx_int_t) n; } - if (n != size) { - ngx_log_error(NGX_LOG_ALERT, ctx->pool->log, 0, - ngx_read_file_n " read only %z of %O from \"%s\"", - n, size, src->file->name.data); - return NGX_ERROR; - } - dst->last += n; if (sendfile) { diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c index a7b389444..df4c2eece 100644 --- a/src/event/ngx_event_openssl.c +++ b/src/event/ngx_event_openssl.c @@ -4407,13 +4407,6 @@ ngx_ssl_session_ticket_keys(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_array_t *paths) goto failed; } - if ((size_t) n != size) { - ngx_conf_log_error(NGX_LOG_CRIT, cf, 0, - ngx_read_file_n " \"%V\" returned only " - "%z bytes instead of %uz", &file.name, n, size); - goto failed; - } - key = ngx_array_push(keys); if (key == NULL) { goto failed; diff --git a/src/http/modules/ngx_http_geo_module.c b/src/http/modules/ngx_http_geo_module.c index 75c03978a..ff3cd04d2 100644 --- a/src/http/modules/ngx_http_geo_module.c +++ b/src/http/modules/ngx_http_geo_module.c @@ -1486,13 +1486,6 @@ ngx_http_geo_include_binary_base(ngx_conf_t *cf, ngx_http_geo_conf_ctx_t *ctx, goto failed; } - if ((size_t) n != size) { - ngx_conf_log_error(NGX_LOG_CRIT, cf, 0, - ngx_read_file_n " \"%s\" returned only %z bytes instead of %z", - name->data, n, size); - goto failed; - } - header = (ngx_http_geo_header_t *) base; if (size < 16 || ngx_memcmp(&ngx_http_geo_header, header, 12) != 0) { diff --git a/src/http/modules/ngx_http_mp4_module.c b/src/http/modules/ngx_http_mp4_module.c index b7bd192df..3d998c250 100644 --- a/src/http/modules/ngx_http_mp4_module.c +++ b/src/http/modules/ngx_http_mp4_module.c @@ -1090,13 +1090,6 @@ ngx_http_mp4_read(ngx_http_mp4_file_t *mp4, size_t size) return NGX_ERROR; } - if ((size_t) n != mp4->buffer_size) { - ngx_log_error(NGX_LOG_CRIT, mp4->file.log, 0, - ngx_read_file_n " read only %z of %z from \"%s\"", - n, mp4->buffer_size, mp4->file.name.data); - return NGX_ERROR; - } - mp4->buffer_pos = mp4->buffer_start; mp4->buffer_end = mp4->buffer_start + mp4->buffer_size; diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c index 5209f003b..7f27c3fe8 100644 --- a/src/http/ngx_http_file_cache.c +++ b/src/http/ngx_http_file_cache.c @@ -1554,13 +1554,6 @@ ngx_http_file_cache_update_header(ngx_http_request_t *r) goto done; } - if ((size_t) n != sizeof(ngx_http_file_cache_header_t)) { - ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0, - ngx_read_file_n " read only %z of %z from \"%s\"", - n, sizeof(ngx_http_file_cache_header_t), file.name.data); - goto done; - } - if (h.version != NGX_HTTP_CACHE_VERSION || h.last_modified != c->last_modified || h.crc32 != c->crc32 diff --git a/src/http/v3/ngx_http_v3_module.c b/src/http/v3/ngx_http_v3_module.c index 139bd65f3..5bd5cfff6 100644 --- a/src/http/v3/ngx_http_v3_module.c +++ b/src/http/v3/ngx_http_v3_module.c @@ -361,13 +361,6 @@ ngx_http_quic_host_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) goto failed; } - if ((size_t) n != size) { - ngx_conf_log_error(NGX_LOG_CRIT, cf, 0, - ngx_read_file_n " \"%V\" returned only " - "%z bytes instead of %uz", &file.name, n, size); - goto failed; - } - qcf->host_key.data = buf; qcf->host_key.len = n; diff --git a/src/stream/ngx_stream_geo_module.c b/src/stream/ngx_stream_geo_module.c index 2324bef0d..910915c20 100644 --- a/src/stream/ngx_stream_geo_module.c +++ b/src/stream/ngx_stream_geo_module.c @@ -1412,13 +1412,6 @@ ngx_stream_geo_include_binary_base(ngx_conf_t *cf, goto failed; } - if ((size_t) n != size) { - ngx_conf_log_error(NGX_LOG_CRIT, cf, 0, - ngx_read_file_n " \"%s\" returned only %z bytes instead of %z", - name->data, n, size); - goto failed; - } - header = (ngx_stream_geo_header_t *) base; if (size < 16 || ngx_memcmp(&ngx_stream_geo_header, header, 12) != 0) { |
