Re: httpd errdocs bug

Фёдор <[email protected]> Fri, 19 Jun 2026 12:14:12 +0300
Newsgroups gmane.os.openbsd.bugs
Message-ID <[email protected]>
------NZDAZEP8CKA2OR7TQQ8DFM28ALGYOY
Content-Type: text/plain;
 charset=utf-8
Content-Transfer-Encoding: quoted-printable

the problem is with the server_dump function=2E for some reason, it doesn't=
 send the buffer completely=2E you can verify this by outputting the buffer=
 length before writing

19 =D0=B8=D1=8E=D0=BD=D1=8F 2026=E2=80=AF=D0=B3=2E 04:14:00 GMT+03:00, Llo=
yd <ng2d68@proton=2Eme> =D0=BF=D0=B8=D1=88=D0=B5=D1=82:
>I do suspect a bug in the errdocs code but unrelated to file size=2E
>
>server_abort_http() uses strlen() to re-calculate the Content-Length of t=
he
>errdoc=2E This is very wrong because embedded NULs in the file body will =
cause
>a truncated value=2E A NUL at 40k will cause it to be truncated as such=
=2E
>
>AFAIK 0x00 are valid characters in Unicode response bodies=2E
>
>read_errdoc() should be modified to return the number of bytes read from
>fstat()=2E It does calculate this but the value is discarded and not retu=
rned=2E
>
>Oddly the comments for read_errdoc() do not match the code that follows,
>because it returns a pointer to the file contents, not a length:
>
>/*
> * return -1 on failure, strlen() of read file otherwise=2E
> * body is NULL on failure, contents of file with trailing \0 otherwise=
=2E
> */
>
>The mismatched documentation has been there since the original commit=2E
>
>Regards
>Lloyd
>
>=D0=A4=D1=91=D0=B4=D0=BE=D1=80 <fedorgorlenko@gmail=2Ecom> wrote:
>
>> error in errdocs in httpd=2E when creating a large html page for an err=
or, it truncates it to 40 kilobytes=2E
>

------NZDAZEP8CKA2OR7TQQ8DFM28ALGYOY
Content-Type: text/html;
 charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div dir=3D"auto">the problem is with the server_d=
ump function=2E for some reason, it doesn't send the buffer completely=2E y=
ou can verify this by outputting the buffer length before writing</div><br>=
<br><div class=3D"gmail_quote"><div dir=3D"auto">19 =D0=B8=D1=8E=D0=BD=D1=
=8F 2026=E2=80=AF=D0=B3=2E 04:14:00 GMT+03:00, Lloyd &lt;ng2d68@proton=2Eme=
&gt; =D0=BF=D0=B8=D1=88=D0=B5=D1=82:</div><blockquote class=3D"gmail_quote"=
 style=3D"margin: 0pt 0pt 0pt 0=2E8ex; border-left: 1px solid rgb(204, 204,=
 204); padding-left: 1ex;">
<pre class=3D"com-fsck-k9__plain-text-message-pre"><div dir=3D"auto">I do =
suspect a bug in the errdocs code but unrelated to file size=2E<br><br>serv=
er_abort_http() uses strlen() to re-calculate the Content-Length of the<br>=
errdoc=2E This is very wrong because embedded NULs in the file body will ca=
use<br>a truncated value=2E A NUL at 40k will cause it to be truncated as s=
uch=2E<br><br>AFAIK 0x00 are valid characters in Unicode response bodies=2E=
<br><br>read_errdoc() should be modified to return the number of bytes read=
 from<br>fstat()=2E It does calculate this but the value is discarded and n=
ot returned=2E<br><br>Oddly the comments for read_errdoc() do not match the=
 code that follows,<br>because it returns a pointer to the file contents, n=
ot a length:<br><br>/*<br> * return -1 on failure, strlen() of read file ot=
herwise=2E<br> * body is NULL on failure, contents of file with trailing \0=
 otherwise=2E<br> */<br><br>The mismatched documentation has been there sin=
ce the original commit=2E<br><br>Regards<br>Lloyd<br><br>=D0=A4=D1=91=D0=B4=
=D0=BE=D1=80 &lt;fedorgorlenko@gmail=2Ecom&gt; wrote:<br><br></div><blockqu=
ote class=3D"gmail_quote" style=3D"margin-bottom: 1ex; --com-fsck-k9__block=
quote-default-border-color: #729fcf;"><div dir=3D"auto">error in errdocs in=
 httpd=2E when creating a large html page for an error, it truncates it to =
40 kilobytes=2E<br></div></blockquote><div dir=3D"auto"><br></div></pre></b=
lockquote></div></body></html>
------NZDAZEP8CKA2OR7TQQ8DFM28ALGYOY--