Skip to content

Commit 47fde32

Browse files
committed
use BIO APIs instead of ReadFileToString
1 parent eb7eb82 commit 47fde32

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

tool-openssl/pkeyutl_test.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,22 @@ TEST_F(PKeyUtlTest, VerifyTest) {
119119
// Just opening and closing the file
120120
}
121121
fprintf(stderr, "DEBUG: Now reading with ReadFileToString\n");
122-
std::string output = ReadFileToString(out_path);
122+
// Create a BIO for reading the file
123+
bssl::UniquePtr<BIO> bio(BIO_new_file(out_path, "rb"));
124+
ASSERT_TRUE(bio);
125+
126+
// Read the file contents
127+
const int buffer_size = 1024;
128+
std::vector<char> buffer(buffer_size);
129+
std::string output;
130+
int bytes_read;
131+
132+
while ((bytes_read = BIO_read(bio.get(), buffer.data(), buffer_size)) > 0) {
133+
output.append(buffer.data(), bytes_read);
134+
}
135+
123136
fprintf(stderr, "DEBUG: Output file content length: %zu\n", output.length());
124137
ASSERT_NE(output.find("Signature Verified Successfully"), std::string::npos);
125-
fprintf(stderr, "DEBUG: VerifyTest completed successfully\n");
126138
}
127139
}
128140

0 commit comments

Comments
 (0)