Commit 6c74a8a
committed
miltertest: fix stack overflow when milter replaces body > BUFRSZ bytes
mt_milter_read() read the protocol-specified payload length directly into
a caller-supplied fixed-size stack buffer with no bounds check. When a
milter sends SMFIR_REPLBODY with a body larger than BUFRSZ (1024 bytes)
the read() overflows the buffer.
Split header parsing into a static mt_milter_read_hdr() helper, and add a
bounds check in mt_milter_read() so oversized payloads fail cleanly instead
of silently corrupting the stack.
Fix mt_eom() to call mt_milter_read_hdr() directly and dynamically allocate
a heap buffer (dynbuf) when the payload exceeds BUFRSZ. The stack buffer
is used for normal-sized responses; dynbuf is freed after each iteration.
This allows SMFIR_REPLBODY of any size to be received and stored correctly.
Fixes #66.1 parent f9ad07a commit 6c74a8a
1 file changed
Lines changed: 95 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
403 | 403 | | |
404 | 404 | | |
405 | 405 | | |
406 | | - | |
| 406 | + | |
407 | 407 | | |
408 | 408 | | |
409 | | - | |
| 409 | + | |
410 | 410 | | |
411 | | - | |
412 | | - | |
413 | | - | |
| 411 | + | |
| 412 | + | |
414 | 413 | | |
415 | 414 | | |
416 | 415 | | |
417 | 416 | | |
418 | | - | |
419 | | - | |
| 417 | + | |
| 418 | + | |
420 | 419 | | |
421 | 420 | | |
422 | | - | |
423 | 421 | | |
424 | 422 | | |
425 | 423 | | |
| |||
461 | 459 | | |
462 | 460 | | |
463 | 461 | | |
464 | | - | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
465 | 490 | | |
466 | 491 | | |
467 | 492 | | |
468 | | - | |
| 493 | + | |
469 | 494 | | |
470 | | - | |
471 | | - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
472 | 506 | | |
473 | 507 | | |
474 | 508 | | |
475 | | - | |
| 509 | + | |
476 | 510 | | |
477 | 511 | | |
478 | 512 | | |
| |||
486 | 520 | | |
487 | 521 | | |
488 | 522 | | |
489 | | - | |
| 523 | + | |
490 | 524 | | |
491 | 525 | | |
492 | 526 | | |
| |||
3072 | 3106 | | |
3073 | 3107 | | |
3074 | 3108 | | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
3075 | 3112 | | |
3076 | 3113 | | |
3077 | 3114 | | |
| |||
3100 | 3137 | | |
3101 | 3138 | | |
3102 | 3139 | | |
3103 | | - | |
| 3140 | + | |
| 3141 | + | |
| 3142 | + | |
3104 | 3143 | | |
3105 | | - | |
| 3144 | + | |
3106 | 3145 | | |
3107 | 3146 | | |
3108 | 3147 | | |
3109 | 3148 | | |
3110 | 3149 | | |
| 3150 | + | |
| 3151 | + | |
| 3152 | + | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
| 3157 | + | |
| 3158 | + | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
| 3171 | + | |
| 3172 | + | |
| 3173 | + | |
| 3174 | + | |
| 3175 | + | |
| 3176 | + | |
| 3177 | + | |
| 3178 | + | |
| 3179 | + | |
| 3180 | + | |
| 3181 | + | |
| 3182 | + | |
3111 | 3183 | | |
3112 | 3184 | | |
3113 | 3185 | | |
3114 | 3186 | | |
3115 | 3187 | | |
| 3188 | + | |
| 3189 | + | |
3116 | 3190 | | |
| 3191 | + | |
3117 | 3192 | | |
3118 | 3193 | | |
3119 | | - | |
| 3194 | + | |
3120 | 3195 | | |
| 3196 | + | |
3121 | 3197 | | |
3122 | 3198 | | |
3123 | 3199 | | |
3124 | 3200 | | |
| 3201 | + | |
| 3202 | + | |
3125 | 3203 | | |
3126 | 3204 | | |
3127 | 3205 | | |
| |||
0 commit comments