From dc25cb3ea43e2ed42d88a761d5fbd69e023ba171 Mon Sep 17 00:00:00 2001
From: Olivier Dion <olivier.dion@savoirfairelinux.com>
Date: Wed, 12 May 2021 09:13:25 -0400
Subject: [PATCH] unitTest/fileTransfer: Fix buffer overflows

Wrong constructor was used, resulting in buffer overflows.  Although it's benign
because of read only of a data section, ASAN doesn't like it at all.

Also added missing newline at end of file.

Signed-off-by: Olivier Dion <olivier.dion@savoirfairelinux.com>
Change-Id: I15553855ea368ec00456db80abb065599adc0d49
---
 test/unitTest/fileTransfer/fileTransfer.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/unitTest/fileTransfer/fileTransfer.cpp b/test/unitTest/fileTransfer/fileTransfer.cpp
index bebcfce447..90d806fbb2 100644
--- a/test/unitTest/fileTransfer/fileTransfer.cpp
+++ b/test/unitTest/fileTransfer/fileTransfer.cpp
@@ -195,7 +195,7 @@ FileTransferTest::testCachedFileTransfer()
     // Create file to send
     std::ofstream sendFile("SEND");
     CPPUNIT_ASSERT(sendFile.is_open());
-    sendFile << std::string("A", 64000);
+    sendFile << std::string(64000, 'A');
     sendFile.close();
 
     // Send File
@@ -268,11 +268,11 @@ FileTransferTest::testMultipleFileTransfer()
     // Create file to send
     std::ofstream sendFile("SEND");
     CPPUNIT_ASSERT(sendFile.is_open());
-    sendFile << std::string("A", 64000);
+    sendFile << std::string(64000, 'A');
     sendFile.close();
     std::ofstream sendFile2("SEND2");
     CPPUNIT_ASSERT(sendFile2.is_open());
-    sendFile2 << std::string("B", 64000);
+    sendFile2 << std::string(64000, 'B');
     sendFile2.close();
 
     // Send first File
@@ -336,4 +336,4 @@ FileTransferTest::testMultipleFileTransfer()
 } // namespace test
 } // namespace jami
 
-RING_TEST_RUNNER(jami::test::FileTransferTest::name())
\ No newline at end of file
+RING_TEST_RUNNER(jami::test::FileTransferTest::name())
-- 
GitLab