added proper expression for comparing write & fread return values

still not complete tho
This commit is contained in:
Václav Šmejkal 2022-12-07 17:30:47 +01:00
parent 8df7a56095
commit fd6aa19eba
No known key found for this signature in database
GPG Key ID: FD749A97DF2D5E19
4 changed files with 4 additions and 4 deletions

View File

@ -58,7 +58,7 @@ outputFlags encryptText(char *text, char *keyNew)
//TRY TO MAKE RANDOM GENERATION REALLY "RANDOM" //TRY TO MAKE RANDOM GENERATION REALLY "RANDOM"
fileBuffer = fopen("/dev/urandom", "r"); fileBuffer = fopen("/dev/urandom", "r");
if (fread(&numberBuffer, sizeof(numberBuffer), 1, fileBuffer) == 0) abort(); //TODO: Make it safe if (fread(&numberBuffer, sizeof(numberBuffer), 1, fileBuffer) != 1) abort(); //TODO: Make it safe
srand(numberBuffer); srand(numberBuffer);
numberBuffer = abs(numberBuffer); //MAKE numberBuffer POSITIVE numberBuffer = abs(numberBuffer); //MAKE numberBuffer POSITIVE

View File

@ -141,7 +141,7 @@ boolean checkVersion()
strcpy(buffer, ""); strcpy(buffer, "");
//LOAD jsonFile //LOAD jsonFile
if (fread(buffer, bufferSize, 1, fileBuffer) == 0) abort(); //TODO: Make it safe if (fread(buffer, bufferSize, 1, fileBuffer) != 1) abort(); //TODO: Make it safe
buffer[bufferSize] = '\0'; buffer[bufferSize] = '\0';

View File

@ -99,7 +99,7 @@ void writeLog(int loggerFile, char *logMessage)
sprintf(buffer, WRITE_FORMATTING, tm.tm_hour, tm.tm_min, tm.tm_sec, logMessage); //LOAD MESSAGE sprintf(buffer, WRITE_FORMATTING, tm.tm_hour, tm.tm_min, tm.tm_sec, logMessage); //LOAD MESSAGE
if (write(loggerFile, buffer, strlen(buffer)) == 0) abort(); //WRITE (YAY) //TODO: Find why the fuck you can't use version line bellow if (write(loggerFile, buffer, strlen(buffer)) != (ssize_t) strlen(buffer)) abort(); //WRITE (YAY) //TODO: Find why the fuck you can't use version line bellow
//(void) write(loggerFile, buffer, strlen(buffer)); //(void) write(loggerFile, buffer, strlen(buffer));
//DEALLOCATION //DEALLOCATION

View File

@ -40,7 +40,7 @@ int main(void)
buffer = malloc(bufferSize + 1); buffer = malloc(bufferSize + 1);
//LOAD jsonFile //LOAD jsonFile
if (fread(buffer, bufferSize, 1, fileBuffer) == 0) abort(); //TODO: Make it safe if (fread(buffer, bufferSize, 1, fileBuffer) != 1) abort(); //TODO: Make it safe
printf("%s\n", buffer); printf("%s\n", buffer);