Skip to content

Commit

Permalink
Fix log buffer overflow error (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
huanghantao authored Jan 4, 2021
1 parent 946a0be commit b3d884a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ void Logger::put(int level, const char *content, size_t length) {
break;
}

// TODO(codinghuang): seems there are "buffer overflow detected" problem
if (length > YASD_MSG_SIZE) {
yasd::Util::printfln_info(yasd::Color::YASD_ECHO_RED, "length is greater than the YASD_MSG_SIZE");
length = YASD_MSG_SIZE;
}
memcpy(yasd_info_buf, content, length);
yasd_info_buf[length] = '\n';
n = length + 1;
Expand Down

0 comments on commit b3d884a

Please sign in to comment.