From 33b0f205738f9e46a1b3e78b77fd9d1f9fb76dad Mon Sep 17 00:00:00 2001 From: Piotr Likoski Date: Fri, 12 Jul 2019 14:10:09 +0200 Subject: [PATCH] Check the snprintf() return value. --- engine/api.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engine/api.c b/engine/api.c index 5c799e9..798437c 100644 --- a/engine/api.c +++ b/engine/api.c @@ -634,7 +634,10 @@ static sxi32 ProcessSourceFile( /* Install local import path which is the current directory */ ph7_vm_config(pVm, PH7_VM_CONFIG_IMPORT_PATH, "./"); if(zFilePath && SyRealPath(zFilePath, fFilePath) == PH7_OK) { - snprintf(pFilePath, sizeof(pFilePath) - 1, "%s", fFilePath); + rc = snprintf(pFilePath, sizeof(pFilePath) - 1, "%s", fFilePath); + if(rc < 0) { + goto Release; + } /* Extract directory name containing processed file */ pFileDir = (char *) PH7_ExtractDirName(fFilePath, SyStrlen(fFilePath), &iFileDir); pFileDir[iFileDir + 1] = '\0';