Minor stuff

This commit is contained in:
Aurora 2016-12-11 20:10:51 +01:00
parent 2f274e2f47
commit f89845257e
4 changed files with 14 additions and 19 deletions

View File

@ -50,7 +50,7 @@ diff -uNr a/source/brahma.c b/source/brahma.c
+ fseek(p , 0, SEEK_END); + fseek(p , 0, SEEK_END);
+ psize = ftell(p); + psize = ftell(p);
+ if (psize > 5 && psize < 58) { + if (psize > 5 && psize < 58) {
+ char path[58]; + char path[57];
+ +
+ fseek(p, 0, SEEK_SET); + fseek(p, 0, SEEK_SET);
+ u32 bytes_read = fread(path, 1, psize, p); + u32 bytes_read = fread(path, 1, psize, p);

View File

@ -43,7 +43,7 @@ void main(void)
if(pathSize > 5 && pathSize < 58) if(pathSize > 5 && pathSize < 58)
{ {
char path[58]; char path[57];
unsigned int read; unsigned int read;
f_read(&pathFile, path, pathSize, &read); f_read(&pathFile, path, pathSize, &read);
if(path[pathSize - 1] == 0xA) pathSize--; if(path[pathSize - 1] == 0xA) pathSize--;

View File

@ -38,19 +38,18 @@
static inline void pathChanger(u8 *pos) static inline void pathChanger(u8 *pos)
{ {
const char *pathFile = "path.txt"; const char *pathFile = "path.txt";
u32 pathSize = getFileSize(pathFile);
if(pathSize < 6 || pathSize > 57) return;
u8 path[57]; u8 path[57];
fileRead(path, pathFile, pathSize);
u32 pathSize = fileRead(path, pathFile, sizeof(path));
if(pathSize < 6) return;
if(path[pathSize - 1] == 0xA) pathSize--; if(path[pathSize - 1] == 0xA) pathSize--;
if(path[pathSize - 1] == 0xD) pathSize--; if(path[pathSize - 1] == 0xD) pathSize--;
if(pathSize < 6 || pathSize > 57 || path[0] != '/' || memcmp(path + pathSize - 4, ".bin", 4) != 0) return; if(pathSize < 6 || pathSize > 55 || path[0] != '/' || memcmp(path + pathSize - 4, ".bin", 4) != 0) return;
u16 finalPath[58]; u16 finalPath[56];
for(u32 i = 0; i < pathSize; i++) for(u32 i = 0; i < pathSize; i++)
finalPath[i] = (u16)path[i]; finalPath[i] = (u16)path[i];

View File

@ -150,18 +150,14 @@ bool verifyPin(u32 pinMode)
drawCharacter('0' + lengthBlock[0], true, 10 + 5 * SPACING_X, 10 + 3 * SPACING_Y, COLOR_WHITE); drawCharacter('0' + lengthBlock[0], true, 10 + 5 * SPACING_X, 10 + 3 * SPACING_Y, COLOR_WHITE);
const char *messageFile = "pinmessage.txt"; const char *messageFile = "pinmessage.txt";
char message[801];
u32 messageSize = getFileSize(messageFile); u32 messageSize = fileRead(message, messageFile, sizeof(message) - 1);
if(messageSize > 0 && messageSize <= 800) if(messageSize != 0)
{ {
char message[801]; message[messageSize] = 0;
drawString(message, false, 10, 10, COLOR_WHITE);
if(fileRead(message, messageFile, messageSize) == messageSize)
{
message[messageSize] = 0;
drawString(message, false, 10, 10, COLOR_WHITE);
}
} }
//Pad to AES block length with zeroes //Pad to AES block length with zeroes