Added ASAN option to build. Fixed several stack bugs.

This commit is contained in:
Scott Duensing 2022-02-23 17:05:50 -06:00
parent 1427b28d00
commit b8e2178775
9 changed files with 24 additions and 18 deletions

View file

@ -21,6 +21,7 @@
TEMPLATE = app TEMPLATE = app
CONFIG -= qt CONFIG -= qt
#CONFIG += ASAN
DESTDIR = $$OUT_PWD/bin DESTDIR = $$OUT_PWD/bin
SHARED = $$PWD/../shared SHARED = $$PWD/../shared
@ -171,6 +172,11 @@ OTHER_FILES = \
$$DOS_SOURCES \ $$DOS_SOURCES \
postBuild.sh postBuild.sh
ASAN {
QMAKE_CFLAGS += -fsanitize=address -g
QMAKE_LFLAGS += -fsanitize=address -static-libasan
}
QMAKE_POST_LINK = $$PWD/postBuild.sh "$$PWD" "$$DESTDIR" QMAKE_POST_LINK = $$PWD/postBuild.sh "$$PWD" "$$DESTDIR"
DISTFILES += DISTFILES +=

View file

@ -244,6 +244,7 @@ static void packetHandler(PacketDecodeDataT *packet) {
_handle = NULL; _handle = NULL;
// Update cache entry to include SHA. // Update cache entry to include SHA.
cacheEntryAdd(_currentSha256, cacheEntryNameGet(_file), _file); cacheEntryAdd(_currentSha256, cacheEntryNameGet(_file), _file);
DEL(_currentSha256);
// Next file! // Next file!
fileCheckNext(); fileCheckNext();
} else { } else {

View file

@ -26,7 +26,7 @@
#include "vesa.h" #include "vesa.h"
static ImageT *imageNativeImageGet(unsigned char *raw, uint16_t x, uint16_t y); static ImageT *imageNativeImageGet(unsigned char *raw, uint32_t x, uint32_t y);
ImageT *imageAllocate(uint16_t w, uint16_t h) { ImageT *imageAllocate(uint16_t w, uint16_t h) {
@ -118,9 +118,9 @@ uint8_t imageInfoGet(char *filename, uint16_t *width, uint16_t *height) {
ImageT *imageLoad(char *filename) { ImageT *imageLoad(char *filename) {
uint16_t x; uint32_t x;
uint16_t y; uint32_t y;
uint16_t n; uint32_t n;
unsigned char *raw; unsigned char *raw;
// Load image from disk // Load image from disk
@ -131,7 +131,7 @@ ImageT *imageLoad(char *filename) {
} }
static ImageT *imageNativeImageGet(unsigned char *raw, uint16_t x, uint16_t y) { static ImageT *imageNativeImageGet(unsigned char *raw, uint32_t x, uint32_t y) {
uint32_t b; uint32_t b;
ImageT *image; ImageT *image;

View file

@ -170,7 +170,7 @@ void loginShow() {
static void packetHandler(PacketDecodeDataT *packet) { static void packetHandler(PacketDecodeDataT *packet) {
char *packetData; char *packetData;
int8_t success; int32_t success;
switch (packet->packetType) { switch (packet->packetType) {
case PACKET_TYPE_LOGIN_RESULT: case PACKET_TYPE_LOGIN_RESULT:

View file

@ -130,7 +130,7 @@ static void btnSignUpClick(WidgetT *widget) {
static void packetHandler(PacketDecodeDataT *packet) { static void packetHandler(PacketDecodeDataT *packet) {
uint16_t length; uint32_t length;
char *packetData; char *packetData;
// Reset timeout. // Reset timeout.

View file

@ -22,6 +22,7 @@ CONFIG -= qt
CONFIG += \ CONFIG += \
console \ console \
c11 c11
# ASAN
DESTDIR = $$OUT_PWD/bin DESTDIR = $$OUT_PWD/bin
SHARED = $$PWD/../shared SHARED = $$PWD/../shared
@ -101,3 +102,8 @@ LIBS = \
-ljson-c -ljson-c
OTHER_FILES = OTHER_FILES =
ASAN {
QMAKE_CFLAGS += -fsanitize=address -g
QMAKE_LFLAGS += -fsanitize=address -static-libasan
}

View file

@ -93,7 +93,7 @@ static void clientApiFileRequestCheck(ClientThreadT *client, PacketDecodeDataT *
logWrite("[%s] [%s]\n\r", sha256, path); logWrite("[%s] [%s]\n\r", sha256, path);
// Look up the entry and compare SHA256. // Look up the entry and compare SHA256.
dbFileSha256Get(path, shaInDB, FILE_VIRTUAL_PATH_MAX); dbFileSha256Get(path, shaInDB, 128);
if (strcasecmp(sha256, shaInDB) == 0) { if (strcasecmp(sha256, shaInDB) == 0) {
logWrite("File is current. Sending FILE_RESPONSE_OKAY.\n\r"); logWrite("File is current. Sending FILE_RESPONSE_OKAY.\n\r");
// File is already current on client. // File is already current on client.

View file

@ -37,7 +37,7 @@ uint8_t __restAvailable = 1;
// "Config" items come from the INI file. "Settings" are from the database. // "Config" items come from the INI file. "Settings" are from the database.
static char *_configServer = NULL; static char *_configServer = NULL;
static uint16_t _configPort = 0; static uint32_t _configPort = 0;
static char *_configDatabase = NULL; static char *_configDatabase = NULL;
static char *_configUser = NULL; static char *_configUser = NULL;
static char *_configPassword = NULL; static char *_configPassword = NULL;

View file

@ -568,16 +568,9 @@ PacketThreadDataT *packetThreadDataCreate(void *senderData) {
data = (PacketThreadDataT *)malloc(sizeof(PacketThreadDataT)); data = (PacketThreadDataT *)malloc(sizeof(PacketThreadDataT));
if (data) { if (data) {
/* memset(data, 0, sizeof(PacketThreadDataT));
data->sequence = 0;
data->lastRemoteSequence = 0;
data->historyPosition = 0;
*/
data->decodeQueueHead = 0;
data->decodeQueueTail = 0;
data->newPacket = 1; data->newPacket = 1;
data->senderData = senderData; data->senderData = senderData;
data->aesContext = NULL;
} }
return data; return data;