You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/10/17 17:28:30 UTC
[GitHub] andrzej-kaczmarek closed pull request #1463: tinyprintf: Limit
allowed values for variable field length
andrzej-kaczmarek closed pull request #1463: tinyprintf: Limit allowed values for variable field length
URL: https://github.com/apache/mynewt-core/pull/1463
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/libc/baselibc/src/tinyprintf.c b/libc/baselibc/src/tinyprintf.c
index 311093103b..5a15015729 100644
--- a/libc/baselibc/src/tinyprintf.c
+++ b/libc/baselibc/src/tinyprintf.c
@@ -64,6 +64,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdarg.h>
#include <stdio.h>
#include <inttypes.h>
+#include <limits.h>
#include "os/mynewt.h"
@@ -244,6 +245,7 @@ size_t tfp_format(FILE *putp, const char *fmt, va_list va)
double d;
int n;
#endif
+ int i;
p.bf = bf;
@@ -283,7 +285,12 @@ size_t tfp_format(FILE *putp, const char *fmt, va_list va)
/* Width */
if (ch == '*') {
- p.width = intarg(0, 1, &va);
+ i = intarg(0, 1, &va);
+ if (i > UCHAR_MAX) {
+ p.width = UCHAR_MAX;
+ } else if (i > 0) {
+ p.width = i;
+ }
ch = *(fmt++);
} else if (ch >= '0' && ch <= '9') {
ch = a2i(ch, &fmt, 10, &(p.width));
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services