diff options
Diffstat (limited to 'src/packet/record.c')
-rw-r--r-- | src/packet/record.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/packet/record.c b/src/packet/record.c index a21d852..53934ed 100644 --- a/src/packet/record.c +++ b/src/packet/record.c @@ -357,8 +357,12 @@ static void write_caa_record(PacketBuffer* buffer, CAARecord* data) { static void write_string(TXTRecord* record, uint8_t* capacity, const char* string, uint8_t len) { if (len < 1) return; - if (record->len == *capacity) { - *capacity *= 2; + if (record->len >= *capacity) { + if (*capacity >= 128) { + *capacity = 255; + } else { + *capacity *= 2; + } record->text = realloc(record->text, sizeof(uint8_t*) * *capacity); } record->text[record->len] = malloc(len + 1); @@ -394,8 +398,11 @@ static void write_cmd_record(PacketBuffer* buffer, CMDRecord* data) { int i = 0; while (1) { - if ((c = getc(output)) == EOF) { - write_string(&res, &capacity, in, i + 1); + if (res.len >= 255) break; + + c = getc(output); + if (c == EOF || c == '\0') { + write_string(&res, &capacity, in, i); break; } |