@@ -289,12 +289,14 @@ do { \
289
289
do { \
290
290
WARN_ON_ONCE(!TFW_STR_EMPTY(&it->hdr)); \
291
291
if (state & HPACK_FLAGS_HUFFMAN_NAME) { \
292
- BUFFER_GET(length, it); \
292
+ unsigned long len = length + (length >> 1); \
293
+ \
294
+ BUFFER_GET(len, it); \
293
295
if (!it->pos) { \
294
296
r = -ENOMEM; \
295
297
goto out; \
296
298
} \
297
- BUFFER_HDR_INIT(length , it); \
299
+ BUFFER_HDR_INIT(len , it); \
298
300
} \
299
301
} while (0)
300
302
@@ -306,13 +308,15 @@ do { \
306
308
? it->parsed_hdr->nchunks \
307
309
: 1; \
308
310
if (state & HPACK_FLAGS_HUFFMAN_VALUE) { \
309
- BUFFER_GET(length, it); \
311
+ unsigned long len = length + (length >> 1); \
312
+ \
313
+ BUFFER_GET(len, it); \
310
314
if (!it->pos) { \
311
315
r = -ENOMEM; \
312
316
goto out; \
313
317
} \
314
318
if (!TFW_STR_EMPTY(&it->hdr)) { \
315
- r = tfw_hpack_exp_hdr(req->pool, length, \
319
+ r = tfw_hpack_exp_hdr(req->pool, len, \
316
320
it); \
317
321
if (unlikely(r)) \
318
322
return r; \
@@ -502,14 +506,28 @@ huffman_decode_tail(TfwHPack *__restrict hp, TfwHttpReq *__restrict req,
502
506
unsigned int i ;
503
507
int r ;
504
508
509
+ #define ADJUST_EXTRA_RSPACE (req ) \
510
+ do { \
511
+ TfwMsgParseIter *it = &req->pit; \
512
+ TfwStr *hdr = &it->hdr; \
513
+ TfwStr *last = TFW_STR_LAST(hdr); \
514
+ \
515
+ hdr->len -= it->rspace; \
516
+ if (!TFW_STR_PLAIN(hdr)) \
517
+ last->len -= it->rspace; \
518
+ it->rspace = 0; \
519
+ } while (0)
520
+
505
521
for (;;) {
506
522
int shift ;
507
523
508
524
if (hp -> curr == - HT_NBITS ) {
509
- if (likely (offset == 0 ))
525
+ if (likely (offset == 0 )) {
526
+ ADJUST_EXTRA_RSPACE (req );
510
527
return T_OK ;
511
- else
528
+ } else {
512
529
return T_COMPRESSION ;
530
+ }
513
531
}
514
532
515
533
i = (hp -> hctx << - hp -> curr ) & HT_NMASK ;
@@ -537,7 +555,8 @@ huffman_decode_tail(TfwHPack *__restrict hp, TfwHttpReq *__restrict req,
537
555
if (likely (offset == 0 )) {
538
556
if ((i ^ (HT_EOS_HIGH >> 1 )) <
539
557
(1U << - hp -> curr )) {
540
- return 0 ;
558
+ ADJUST_EXTRA_RSPACE (req );
559
+ return T_OK ;
541
560
}
542
561
}
543
562
/*
@@ -563,10 +582,13 @@ huffman_decode_tail(TfwHPack *__restrict hp, TfwHttpReq *__restrict req,
563
582
}
564
583
if (likely (offset == 0 )) {
565
584
if ((i ^ (HT_EOS_HIGH >> 1 )) < (1U << - hp -> curr )) {
585
+ ADJUST_EXTRA_RSPACE (req );
566
586
return T_OK ;
567
587
}
568
588
}
569
589
return T_COMPRESSION ;
590
+
591
+ #undef ADJUST_EXTRA_RSPACE
570
592
}
571
593
572
594
static int
0 commit comments