From: Daniel Stenberg Date: Fri, 17 Oct 2025 15:05:08 +0000 (+0200) Subject: rustls: make read_file_into not reject good files X-Git-Tag: rc-8_17_0-3~137 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9455ea523d91c8f6f29c3ae1f37500f0b637204;p=thirdparty%2Fcurl.git rustls: make read_file_into not reject good files For files with sizes using an exact multiple of 256 bytes, the final successful read(s) filled the buffer(s) and the subsequent fread returned 0 for EOF, which caused read_file_into to fail. Now, it needs to return 0 and not be EOF to be an error. Follow-up to dd95a49d493d55db38b352fdbda2 Pointed out by ZeroPath Closes #19104 --- diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c index 38e8a697a8..ebd94213d4 100644 --- a/lib/vtls/rustls.c +++ b/lib/vtls/rustls.c @@ -404,8 +404,8 @@ read_file_into(const char *filename, for(;;) { uint8_t buf[256]; const size_t rr = fread(buf, 1, sizeof(buf), f); - if(rr == 0 || - CURLE_OK != curlx_dyn_addn(out, buf, rr)) { + if((!rr && !feof(f)) || + curlx_dyn_addn(out, buf, rr)) { curlx_fclose(f); return 0; }