From: zriback Date: Thu, 30 Jan 2025 16:41:15 +0000 (-0500) Subject: Fix issue where file is not read correctly with Windows line endings X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f15a2a43ef2df3a6131156e0a88fa44238fb034e;p=thirdparty%2Fopenssl.git Fix issue where file is not read correctly with Windows line endings Reviewed-by: Paul Dale Reviewed-by: Viktor Dukhovni (Merged from https://github.com/openssl/openssl/pull/26549) --- diff --git a/apps/prime.c b/apps/prime.c index cbbcd4262ff..4c103e975fc 100644 --- a/apps/prime.c +++ b/apps/prime.c @@ -172,8 +172,10 @@ opthelp: file_read_buf = (char *)realloc(file_read_buf, BUFSIZE + total_read); } - /* Trim trailing newline if present */ - if (file_read_buf[total_read - 1] == '\n') + /* Deal with Unix and Windows line endings */ + if (file_read_buf[total_read - 2] == '\r') + file_read_buf[total_read - 2] = '\0'; + else if (file_read_buf[total_read - 1] == '\n') file_read_buf[total_read - 1] = '\0'; check_val = file_read_buf;