Skip to content

Commit

Permalink
Fix vtsn.len type #269
Browse files Browse the repository at this point in the history
  • Loading branch information
u5surf committed Apr 16, 2023
1 parent dd6930c commit 30a38c5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ngx_http_vhost_traffic_status_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ ngx_http_vhost_traffic_status_dump_restore(ngx_event_t *ev)
/* read: data */
offset += n;
n = ngx_read_file(&file, buf, vtsn.len, offset);
if (n != vtsn.len) {
if (n >= 0 && vtsn.len <= SSIZE_MAX && n != (ssize_t) vtsn.len) {
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, ev->log, 0,
"dump_restore::ngx_read_file() read:%z, data:%z failed",
n, vtsn.len);
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_vhost_traffic_status_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ typedef struct {
#endif

ngx_http_vhost_traffic_status_node_upstream_t stat_upstream;
u_short len;
size_t len;
u_char data[1];
} ngx_http_vhost_traffic_status_node_t;

Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_vhost_traffic_status_shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ ngx_http_vhost_traffic_status_shm_add_node(ngx_http_request_t *r,
vtsn = (ngx_http_vhost_traffic_status_node_t *) &node->color;

node->key = hash;
vtsn->len = (u_short) key->len;
vtsn->len = key->len;
ngx_http_vhost_traffic_status_node_init(r, vtsn);
vtsn->stat_upstream.type = type;
ngx_memcpy(vtsn->data, key->data, key->len);
Expand Down

0 comments on commit 30a38c5

Please sign in to comment.