Mercurial > hg > nginx-quic
comparison src/http/v3/ngx_http_v3_tables.c @ 7886:26cb2f3259b1 quic
HTTP/3: reallocate strings inserted into the dynamic table.
They should always be allocated from the main QUIC connection pool.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Thu, 14 May 2020 16:02:32 +0300 |
parents | f11b7981a03d |
children | c9538aef3211 |
comparison
equal
deleted
inserted
replaced
7885:5b367070cc9c | 7886:26cb2f3259b1 |
---|---|
147 ngx_int_t | 147 ngx_int_t |
148 ngx_http_v3_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic, | 148 ngx_http_v3_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic, |
149 ngx_uint_t index, ngx_str_t *value) | 149 ngx_uint_t index, ngx_str_t *value) |
150 { | 150 { |
151 ngx_array_t *dt; | 151 ngx_array_t *dt; |
152 ngx_connection_t *pc; | |
152 ngx_http_v3_header_t *ref, *h; | 153 ngx_http_v3_header_t *ref, *h; |
153 | 154 |
154 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, | 155 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, |
155 "http3 ref insert %s[$ui] \"%V\"", | 156 "http3 ref insert %s[$ui] \"%V\"", |
156 dynamic ? "dynamic" : "static", index, value); | 157 dynamic ? "dynamic" : "static", index, value); |
157 | 158 |
159 pc = c->qs->parent; | |
160 | |
158 ref = ngx_http_v3_lookup_table(c, dynamic, index); | 161 ref = ngx_http_v3_lookup_table(c, dynamic, index); |
159 if (ref == NULL) { | 162 if (ref == NULL) { |
160 return NGX_ERROR; | 163 return NGX_ERROR; |
161 } | 164 } |
162 | 165 |
169 if (h == NULL) { | 172 if (h == NULL) { |
170 return NGX_ERROR; | 173 return NGX_ERROR; |
171 } | 174 } |
172 | 175 |
173 h->name = ref->name; | 176 h->name = ref->name; |
174 h->value = *value; | 177 |
178 h->value.data = ngx_pstrdup(pc->pool, value); | |
179 if (h->value.data == NULL) { | |
180 h->value.len = 0; | |
181 return NGX_ERROR; | |
182 } | |
183 | |
184 h->value.len = value->len; | |
175 | 185 |
176 if (ngx_http_v3_new_header(c) != NGX_OK) { | 186 if (ngx_http_v3_new_header(c) != NGX_OK) { |
177 return NGX_ERROR; | 187 return NGX_ERROR; |
178 } | 188 } |
179 | 189 |
184 ngx_int_t | 194 ngx_int_t |
185 ngx_http_v3_insert(ngx_connection_t *c, ngx_str_t *name, | 195 ngx_http_v3_insert(ngx_connection_t *c, ngx_str_t *name, |
186 ngx_str_t *value) | 196 ngx_str_t *value) |
187 { | 197 { |
188 ngx_array_t *dt; | 198 ngx_array_t *dt; |
199 ngx_connection_t *pc; | |
189 ngx_http_v3_header_t *h; | 200 ngx_http_v3_header_t *h; |
190 | 201 |
191 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | 202 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
192 "http3 insert \"%V\":\"%V\"", name, value); | 203 "http3 insert \"%V\":\"%V\"", name, value); |
193 | 204 |
205 pc = c->qs->parent; | |
206 | |
194 dt = ngx_http_v3_get_dynamic_table(c); | 207 dt = ngx_http_v3_get_dynamic_table(c); |
195 if (dt == NULL) { | 208 if (dt == NULL) { |
196 return NGX_ERROR; | 209 return NGX_ERROR; |
197 } | 210 } |
198 | 211 |
199 h = ngx_array_push(dt); | 212 h = ngx_array_push(dt); |
200 if (h == NULL) { | 213 if (h == NULL) { |
201 return NGX_ERROR; | 214 return NGX_ERROR; |
202 } | 215 } |
203 | 216 |
204 h->name = *name; | 217 h->name.data = ngx_pstrdup(pc->pool, name); |
205 h->value = *value; | 218 if (h->name.data == NULL) { |
219 h->name.len = 0; | |
220 h->value.len = 0; | |
221 return NGX_ERROR; | |
222 } | |
223 | |
224 h->name.len = name->len; | |
225 | |
226 h->value.data = ngx_pstrdup(pc->pool, value); | |
227 if (h->value.data == NULL) { | |
228 h->value.len = 0; | |
229 return NGX_ERROR; | |
230 } | |
231 | |
232 h->value.len = value->len; | |
206 | 233 |
207 if (ngx_http_v3_new_header(c) != NGX_OK) { | 234 if (ngx_http_v3_new_header(c) != NGX_OK) { |
208 return NGX_ERROR; | 235 return NGX_ERROR; |
209 } | 236 } |
210 | 237 |