From 59191c204ab030aabc34cf758efefdaf2de65401 Mon Sep 17 00:00:00 2001 From: JackCarterSmith Date: Fri, 19 Aug 2022 19:52:26 +0200 Subject: [PATCH] sprintf and strcpy size safety --- obj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/obj.c b/obj.c index 4109b33..69cccbd 100644 --- a/obj.c +++ b/obj.c @@ -497,7 +497,7 @@ static void read_mtl(const char *path, int scanning = 1; int n = 0; - sprintf(pathname, "%s/%s", path, file); + snprintf(pathname, MAXSTR - 1, "%s/%s", path, file); if ((fin = fopen(pathname, "r"))) { @@ -928,7 +928,7 @@ static void read_obj(obj *O, const char *filename) /* Extract the directory from the filename for use in MTL loading. */ - strncpy(D, filename, MAXSTR); + strncpy(D, filename, MAXSTR - 1); dirpath(D); /* Process each line of the OBJ file, invoking the handler for each. */