I have been facing issues while reading file on ARM64 based system as file is getting truncated and able to read partially only. I am able to read the file properly on linux x8664 .
#include <iostream>
#include <fstream>
#include <json/json.h>
int main()
{
Json::Reader reader;
Json::Value root;
std::string filePath = "/usr/data/signature.json";
// Read the JSON content from the file
std::ifstream file(filePath, std::ifstream::binary);
if (!file.is_open())
{
std::cerr << "Error opening file: " << filePath << std::endl;
return 1;
}
bool parsing = reader.parse(file, root, false);
if (!parsing)
{
// report to the user the failure and their locations in the document.
std::cout << reader.getFormatedErrorMessages()
<< "\n";
}
// Extract the signature value from the JSON
std::string signature = root["signature"].asString();
std::cout << "size = " << signature.size() << std::endl;
// Print the extracted signature
std::cout << "Signature string: " << signature << std::endl;
return 0;
}
Here is the signature json file contents:
{
"signature": "3045022100c8365fbdb1c9a54ffa537c52a82d7168887912e23eeed2eacf045e517d08b1f7022033d3dc6a7bd30b8ee7ab652a2522348137d3e48d86a80e68038bd19cd0eae200"
}
and here is the output which i get on aarch64 linux ;
Signature string: 3045022100c8365fbdb1c9a54ffa537c52a82d7168887912e23eeed2eacf045e517d08b1f7022033d3dc6a7bd30b8ee7ab652a2522348137d3e48d86a0
which is different of json file in terms of number of character is printed on console but size is same (142) and this issue is observed on aarch64 GNU/Linux. Any pointers how to troubleshoot this as it looks architecture dependent behavior as Linux x8664 it works fine. so basically problem is string size is coming properly but content which it display it is not complete and when I used this content to verify the signature it didn't work as string should content complete content as kept inside signature.json file. I am not sure how aarch64 is having limit of character to show though printed size is accurate. It looks architecture issue to me as same code work on x8664 linux. Now how to update this code to work properly on aarch64 GNU/Linux.