From 3370d2231cf18d2b5b35c8ee242285bd51e53d5e Mon Sep 17 00:00:00 2001 From: chengjinsong2 Date: Tue, 21 Feb 2023 14:01:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chengjinsong2 --- services/begetctl/misc_daemon.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/begetctl/misc_daemon.cpp b/services/begetctl/misc_daemon.cpp index 2b1d7b02..20135732 100755 --- a/services/begetctl/misc_daemon.cpp +++ b/services/begetctl/misc_daemon.cpp @@ -62,6 +62,11 @@ static void WriteLogoContent(int fd, const std::string &logoPath, uint32_t size) return; } + if (size <= 0 || size > MAX_LOGO_SIZE) { + BSH_LOGE("logo size is invalid!"); + return; + } + char *buffer = reinterpret_cast(malloc(size)); if (buffer == nullptr) { (void)fclose(rgbFile); @@ -120,7 +125,7 @@ static int WriteLogo(int fd, const std::string &logoPath) return -1; } - if (st.st_size < 0 || st.st_size > MAX_LOGO_SIZE) { + if (st.st_size <= 0 || st.st_size > MAX_LOGO_SIZE) { BSH_LOGE("Invalid logo file with size "); ClearLogo(fd); return -1; -- GitLab