Repository navigation
Commit b02f937
BUG/MINOR: sample: fix NULL dereference in the ltime/utime converters
conv_time_common() returns NULL when alloc_trash_chunk() fails, and when
the format string expanded for "%N" does not fit in the trash chunk. Its
four callers, sample_conv_us_ltime(), sample_conv_ms_ltime(),
sample_conv_us_utime() and sample_conv_ms_utime(), dereference the
result without checking it.
A configuration using one of these converters with a long format, e.g.
ms_ltime("%N%N%N...") expanding to more than bufsize, is accepted by
"haproxy -c", and the first request evaluating it crashes the process
with a NULL dereference. A failed allocation at runtime has the same
effect with an ordinary format.
Let's make the converter fail instead, like on its other error paths.
This fixes GitHub issue #3545.
This must be backported to all stable versions up to 3.0, as commit
5e63e16 introduced the first version of conv_time_common() with a
possible NULL return.1 parent e5e52e3 commit b02f937
1 file changed
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2732 | 2732 | | |
2733 | 2733 | | |
2734 | 2734 | | |
| 2735 | + | |
| 2736 | + | |
2735 | 2737 | | |
2736 | 2738 | | |
2737 | 2739 | | |
| |||
2755 | 2757 | | |
2756 | 2758 | | |
2757 | 2759 | | |
| 2760 | + | |
| 2761 | + | |
2758 | 2762 | | |
2759 | 2763 | | |
2760 | 2764 | | |
| |||
2814 | 2818 | | |
2815 | 2819 | | |
2816 | 2820 | | |
| 2821 | + | |
| 2822 | + | |
2817 | 2823 | | |
2818 | 2824 | | |
2819 | 2825 | | |
| |||
2837 | 2843 | | |
2838 | 2844 | | |
2839 | 2845 | | |
| 2846 | + | |
| 2847 | + | |
2840 | 2848 | | |
2841 | 2849 | | |
2842 | 2850 | | |
| |||
0 commit comments