Skip to content

Commit f05eaef

Browse files
committed
Fix buffer overflow for section arm event
1 parent 73ef044 commit f05eaef

4 files changed

Lines changed: 8 additions & 7 deletions

File tree

libdozor/device-event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ unsigned short int getDeviceEvents(const uint8_t * raw, long int bufSize, Device
9797

9898
blobToHexStr(hexStr, &raw[index], eventSize);
9999

100-
logger(LOG_LEVEL_DEBUG, "device-event(getDeviceEvents)", "event id 0x%x: %s", raw[index], hexStr);
100+
logger(LOG_LEVEL_DEBUG, "device-event(getDeviceEvents)", "[%d] event id 0x%x: %s", eventCount, raw[index], hexStr);
101101

102102
free(hexStr);
103103
}

libdozor/event.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,10 @@ static char * getAuthEventData(uint8_t type, uint8_t * data, uint8_t len)
446446
static char * getSecurityEventData(uint8_t type, uint8_t * data, uint8_t len)
447447
{
448448
char * template = ",\"user\":%s,\"event\":\"%s\",\"scope\":\"Security\",\"sections\":%s";
449-
char * res = malloc(sizeof(char) * (strlen(template) + MAX_EVENT_NAME_LENGTH + 2));
449+
char * res = malloc(sizeof(char) * (strlen(template) + MAX_EVENT_NAME_LENGTH + MAX_SECTION_LENGTH + 2));
450450
char * extractedData = getData(data, USER_DATA_POSITION, len);
451451
uint8_t state_byte = data[0];
452-
char affectedSections[50];
452+
char affectedSections[MAX_SECTION_LENGTH];
453453

454454
get_affected_sections(state_byte, affectedSections);
455455

libdozor/event.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#define EVENT_COUNT 64
2626
#define EVENT_TIMESTAMP_LENGTH 25
2727
#define MAX_EVENT_NAME_LENGTH 25
28+
#define MAX_SECTION_LENGTH 22 // like, "[1, 2, 3, 4, 5, 7, 8]"
2829
#define COMMAND_RESULT_COUNT 8
2930
#define MAX_COMMAND_RESULT_NAME_LENGTH 32
3031
#define COMMON_EVENT_SCOPE "Common"

libdozor/rc4.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ void codec(unsigned char* data, CryptoSession * crypto, const size_t msgLength)
5454
unsigned short int data_index;
5555
unsigned char old;
5656

57-
logger(LOG_LEVEL_DEBUG, "rc4(codec)", "called for - %s\n", data);
58-
logger(LOG_LEVEL_DEBUG, "rc4(codec)", "iterator %d\n", i);
59-
logger(LOG_LEVEL_DEBUG, "rc4(codec)", "pointer %d\n", j);
57+
// logger(LOG_LEVEL_DEBUG, "rc4(codec)", "called for - %s\n", data);
58+
// logger(LOG_LEVEL_DEBUG, "rc4(codec)", "iterator %d\n", i);
59+
// logger(LOG_LEVEL_DEBUG, "rc4(codec)", "pointer %d\n", j);
6060

6161
// convert data
6262
for (data_index = 0; data_index < msgLength; data_index++) {
@@ -67,7 +67,7 @@ void codec(unsigned char* data, CryptoSession * crypto, const size_t msgLength)
6767
kword = crypto->pool[(crypto->pool[i] + crypto->pool[j]) % POOL_SIZE];
6868
data[data_index] = old ^ kword;
6969

70-
logger(LOG_LEVEL_DEBUG, "rc4(codec)", "[%d] 0x%x -> 0x%x\n", data_index, old, data[data_index]);
70+
// logger(LOG_LEVEL_DEBUG, "rc4(codec)", "[%d] 0x%x -> 0x%x\n", data_index, old, data[data_index]);
7171
}
7272

7373
crypto->iterator = i;

0 commit comments

Comments
 (0)