sprintf and strcpy size safety

This commit is contained in:
JackCarterSmith 2022-08-19 19:52:26 +02:00
parent 63f5977aae
commit 59191c204a
Signed by: JackCarterSmith
GPG Key ID: 832E52F4E23F8F24

4
obj.c
View File

@ -497,7 +497,7 @@ static void read_mtl(const char *path,
int scanning = 1; int scanning = 1;
int n = 0; int n = 0;
sprintf(pathname, "%s/%s", path, file); snprintf(pathname, MAXSTR - 1, "%s/%s", path, file);
if ((fin = fopen(pathname, "r"))) 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. */ /* Extract the directory from the filename for use in MTL loading. */
strncpy(D, filename, MAXSTR); strncpy(D, filename, MAXSTR - 1);
dirpath(D); dirpath(D);
/* Process each line of the OBJ file, invoking the handler for each. */ /* Process each line of the OBJ file, invoking the handler for each. */