From b10e8ba9b323a996b4f73f49232a6f5433d65fbb Mon Sep 17 00:00:00 2001 From: Matias Israelson <57065102+israpps@users.noreply.github.com> Date: Thu, 7 Nov 2024 08:48:59 -0300 Subject: [PATCH] fix romimg error --- tools/romimg/src/platform.h | 3 --- tools/romimg/src/romimg.c | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tools/romimg/src/platform.h b/tools/romimg/src/platform.h index 0eba7357d90..9d9a5970767 100644 --- a/tools/romimg/src/platform.h +++ b/tools/romimg/src/platform.h @@ -13,8 +13,5 @@ void upperbuff(char *temp); #else #define PATHSEP '/' #endif -#ifndef MAX_PATH -#define MAX_PATH 4096 -#endif #endif /* __PLATFORM_H__ */ diff --git a/tools/romimg/src/romimg.c b/tools/romimg/src/romimg.c index fab351f736b..90eda8b2099 100644 --- a/tools/romimg/src/romimg.c +++ b/tools/romimg/src/romimg.c @@ -143,7 +143,7 @@ static int GetExtInfoStat(const struct ROMImgStat *ImageStat, struct RomDirFileF int CreateBlankROMImg(const char *filename, ROMIMG *ROMImg) { unsigned int CommentLength; - char LocalhostName[32] = "\0", cwd[MAX_PATH] = "\0", UserName[32] = "\0"; + char LocalhostName[32] = {0}, cwd[PATH_MAX] = {0}, UserName[32] = {0}; struct FileEntry *ResetFile; struct ExtInfoFieldEntry *ExtInfoEntry; @@ -158,10 +158,10 @@ int CreateBlankROMImg(const char *filename, ROMIMG *ROMImg) GetLocalhostName(LocalhostName, sizeof(LocalhostName)); GetCurrentWorkingDirectory(cwd, sizeof(cwd)); /* Comment format: YYYYMMDD-XXXYYY,conffile,,@/ */ - CommentLength = IMAGE_COMMENT_BASESIZE + strlen(filename) + sizeof(LocalhostName) + sizeof(UserName) + MAX_PATH; + CommentLength = IMAGE_COMMENT_BASESIZE + strlen(filename) + sizeof(LocalhostName) + sizeof(UserName) + sizeof(cwd); ROMImg->comment = (char *)malloc( CommentLength+1); if (!ROMImg->comment) return ENOMEM; - snprintf(ROMImg->comment, CommentLength, "%08x,conffile,%s,%s@%s/%s", ROMImg->date, filename, BUFCHK(UserName), BUFCHK(LocalhostName), cwd); + snprintf(ROMImg->comment, CommentLength, "%08x,conffile,%s,%s@%s/%s", ROMImg->date, filename, UserName, LocalhostName, cwd); // Create a blank RESET file. ROMImg->NumFiles = 1; @@ -454,7 +454,7 @@ static int AddExtInfoStat(struct FileEntry *file, unsigned char type, void *data int AddFile(ROMIMG *ROMImg, const char *path, int upperconv) { - char tbuf[10] = "\0"; // we dont need a large buf, this is for filling in the filename on ROMFS + char tbuf[9] = "\0"; // we dont need a large buf, this is for filling in the filename on ROMFS FILE *InputFile; int result; unsigned int FileDateStamp;