diff --git a/services/begetctl/misc_daemon.cpp b/services/begetctl/misc_daemon.cpp index 2b1d7b02152dc48cc7633ee8dfc5af03a67efc62..201357322a8bce44e54fafbc5edc1c513766ee77 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;