commit 926dd102f936c780686ab3a8cc0beeca2151210c
parent 6d9057bc85983e6c59db679aaadb2ed4fea2c2ad
Author: Frederic Cambus <fred@statdns.com>
Date: Fri, 16 Nov 2018 14:42:36 +0100
Check for the TUNDRA24 string in TND files header
Diffstat:
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/TODO b/TODO
@@ -9,6 +9,5 @@
- Fuzz with AFL, especially for non ANSI formats
- Allow enabling DOS aspect ratio + retina at the same time
- Split fonts to have one include file per font
-- Check for the TUNDRA24 string in TND files header
- Wrap lines longer than 80 columns
- Add a manual page for the library
diff --git a/src/loaders/tundra.c b/src/loaders/tundra.c
@@ -13,12 +13,14 @@
#include <gd.h>
#include <stddef.h>
#include <stdint.h>
+#include <string.h>
#include "ansilove.h"
#include "drawchar.h"
#include "fonts.h"
#include "output.h"
#define TUNDRA_VERSION 24
+#define TUNDRA_STRING "TUNDRA24"
#define TUNDRA_HEADER_LENGTH 9 /* 8 + 1 */
@@ -56,8 +58,8 @@ int ansilove_tundra(struct ansilove_ctx *ctx, struct ansilove_options *options)
/* extract tundra header */
tundra_version = ctx->buffer[0];
- /* XXX: add check for "TUNDRA24" string in the header */
- if (tundra_version != TUNDRA_VERSION) {
+ if (tundra_version != TUNDRA_VERSION ||
+ strncmp((const char *)ctx->buffer + 1, TUNDRA_STRING, 8)) {
ctx->error = ANSILOVE_FORMAT_ERROR;
return -1;
}