Skip to content

Commit

Permalink
Fix a potential buffer overflow
Browse files Browse the repository at this point in the history
When compiling with -Wformat-overflow=2 GCC reports:
  note: 'sprintf' output between 16 and 35 bytes into a destination of size 32
  • Loading branch information
rkta committed Feb 20, 2022
1 parent cf7058b commit c5c63a1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ writeBufferName(Buffer *buf, int n)
void
gotoLine(Buffer *buf, int n)
{
char msg[32];
char msg[36];
Line *l = buf->firstLine;

if (l == NULL)
Expand Down Expand Up @@ -284,7 +284,7 @@ gotoLine(Buffer *buf, int n)
void
gotoRealLine(Buffer *buf, int n)
{
char msg[32];
char msg[36];
Line *l = buf->firstLine;

if (l == NULL)
Expand Down

2 comments on commit c5c63a1

@N-R-K
Copy link
Contributor

@N-R-K N-R-K commented on c5c63a1 Apr 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rkta wouldn't it be better to just go all the way and switch over to snprintf as well? If truncation is a problem then snprintf's return value can be used to detect it :)

@rkta
Copy link
Contributor Author

@rkta rkta commented on c5c63a1 Oct 11, 2022 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.