This commit is contained in:
maliakal_d 2021-11-11 09:21:21 +01:00
parent 65a2a9eb06
commit 4f6640a6f1

View File

@ -245,7 +245,7 @@ int getModuleIdInFile(int *ret, char *mess, char *fileName) {
int verifyChecksumFromBuffer(char *mess, char *functionType, int verifyChecksumFromBuffer(char *mess, char *functionType,
char *clientChecksum, char *buffer, char *clientChecksum, char *buffer,
ssize_t bytes) { ssize_t bytes) {
LOG(logINFO, ("\tVerifying Checksum...\n")); LOG(logINFO, ("\tVerifying Checksum from memory...\n"));
MD5_CTX c; MD5_CTX c;
if (!MD5_Init_SLS(&c)) { if (!MD5_Init_SLS(&c)) {
sprintf(mess, sprintf(mess,
@ -267,7 +267,7 @@ int verifyChecksumFromBuffer(char *mess, char *functionType,
int verifyChecksumFromFile(char *mess, char *functionType, char *clientChecksum, int verifyChecksumFromFile(char *mess, char *functionType, char *clientChecksum,
char *fname) { char *fname) {
LOG(logINFO, ("\tVerifying Checksum...\n")); LOG(logINFO, ("\tVerifying Checksum of file...\n"));
FILE *fp = fopen(fname, "r"); FILE *fp = fopen(fname, "r");
if (fp == NULL) { if (fp == NULL) {
@ -313,7 +313,7 @@ int verifyChecksumFromFile(char *mess, char *functionType, char *clientChecksum,
int verifyChecksumFromFlash(char *mess, char *functionType, int verifyChecksumFromFlash(char *mess, char *functionType,
char *clientChecksum, char *fname, ssize_t fsize) { char *clientChecksum, char *fname, ssize_t fsize) {
LOG(logINFO, ("\tVerifying FlashChecksum...\n")); LOG(logINFO, ("\tVerifying Checksum from flash...\n"));
FILE *fp = fopen(fname, "r"); FILE *fp = fopen(fname, "r");
if (fp == NULL) { if (fp == NULL) {
@ -495,12 +495,16 @@ int setupDetectorServer(char *mess, char *sname) {
return OK; return OK;
} }
int writeBinaryFile(char* mess, char* fname, char* buffer, const uint64_t filesize) { int writeBinaryFile(char *mess, char *fname, char *buffer,
const uint64_t filesize) {
LOG(logINFO, ("\tWriting Detector Server Binary...\n")); LOG(logINFO, ("\tWriting Detector Server Binary...\n"));
FILE *fp = fopen(fname, "wb"); FILE *fp = fopen(fname, "wb");
if (fp == NULL) { if (fp == NULL) {
sprintf(mess, "Could not copy detector server. (opening file to write(%s). Maybe it is being used? Try another server name?\n", fname); sprintf(mess,
"Could not copy detector server. (opening file to write(%s). "
"Maybe it is being used? Try another server name?\n",
fname);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
return FAIL; return FAIL;
} }
@ -527,18 +531,25 @@ int writeBinaryFile(char* mess, char* fname, char* buffer, const uint64_t filesi
// write // write
if (bytes != (size_t)writeSize) { if (bytes != (size_t)writeSize) {
sprintf(mess, "Could not copy detector server. Expected to write %lu bytes, wrote %lu bytes). No space left? \n", (long unsigned int)filesize, (long unsigned int)bytesWritten); sprintf(mess,
"Could not copy detector server. Expected to write %lu "
"bytes, wrote %lu bytes). No space left? \n",
(long unsigned int)filesize,
(long unsigned int)bytesWritten);
LOG(logERROR, (mess)); LOG(logERROR, (mess));
return FAIL; return FAIL;
} }
bytesWritten += bytes; bytesWritten += bytes;
LOG(logDEBUG1, ("bytesWritten:%lu filesize:%lu\n", bytesWritten, filesize)); LOG(logDEBUG1,
("bytesWritten:%lu filesize:%lu\n", bytesWritten, filesize));
} }
if (fclose(fp) != 0) { if (fclose(fp) != 0) {
sprintf(mess, "Could not copy detector server. (closing file pointer)\n"); sprintf(mess,
"Could not copy detector server. (closing file pointer)\n");
LOG(logERROR, (mess)); LOG(logERROR, (mess));
return FAIL; return FAIL;
} }
LOG(logINFO, ("\tWritten server binary to %s (%lu bytes)\n", fname, (long unsigned int)bytesWritten)); LOG(logINFO, ("\tWritten server binary to %s (%lu bytes)\n", fname,
(long unsigned int)bytesWritten));
return OK; return OK;
} }