diff --git a/app/main.c b/app/main.c index 7478890..a3c7811 100644 --- a/app/main.c +++ b/app/main.c @@ -7,6 +7,7 @@ #include #include #include +#include #define TILESIZE 32 #define WINWIDTH 30 @@ -26,6 +27,8 @@ static unsigned map[MAPWIDTH][MAPHEIGHT]; int main(int argc, char *argv[]) { + char path[MAX_PATH_LEN]; + if (2 != argc) { fprintf(stderr, "Usage: %s ASSETS-DIR\n", argv[0]); return 1; @@ -42,10 +45,10 @@ int main(int argc, char *argv[]) xmlDocPtr doc; xmlNodePtr node; - char mappath[MAX_PATH_LEN]; - strncpy(mappath, argv[1], MAX_PATH_LEN); - strncat(mappath, MAP_ASSET, MAX_PATH_LEN); - doc = xmlParseFile(mappath); + assert(strlen(argv[1]) + strlen(MAP_ASSET) < MAX_PATH_LEN); + strcpy(path, argv[1]); + strcat(path, MAP_ASSET); + doc = xmlParseFile(path); assert(NULL != doc); node = xmlDocGetRootElement(doc); assert(0 == xmlStrcmp(node->name, (const xmlChar *)"map"));