Skip to content

Commit

Permalink
print: fix global-buffer-overflow in print module
Browse files Browse the repository at this point in the history
  • Loading branch information
zpl-zak authored Sep 11, 2022
1 parent fe64cd4 commit 671f30d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
18.0.1 - Fix ADT parser wrongly assuming that an IP address is a real number.
18.0.2 - fix global-buffer-overflow in print module
18.0.1 - fix ADT parser wrongly assuming that an IP address is a real number
18.0.0 - removed coroutines module
- removed timer module
- rename zpl_adt_get -> zpl_adt_query
Expand Down
2 changes: 2 additions & 0 deletions code/source/core/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ zpl_internal zpl_isize zpl__print_string(char *text, zpl_isize max_len, zpl__for

if (info && (info->width == 0 || info->flags & ZPL_FMT_MINUS)) {
if (info->precision > 0) len = info->precision < len ? info->precision : len;
if (res+len > max_len) return res;
res += zpl_strlcpy(text, str, len);
text += res;

Expand All @@ -159,6 +160,7 @@ zpl_internal zpl_isize zpl__print_string(char *text, zpl_isize max_len, zpl__for
while (padding-- > 0 && remaining-- > 0) *text++ = pad, res++;
}

if (res+len > max_len) return res;
res += zpl_strlcpy(text, str, len);
}

Expand Down

0 comments on commit 671f30d

Please sign in to comment.