Bugzilla – Attachment 3042 Details for
Bug 2769
String truncation warnings in fmt_scaled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Help compiler prove that fmt_scaled snprintf fits
0001-Help-compiler-prove-that-fmt_scaled-snprintf-fits.patch (text/plain), 983 bytes, created by
Colin Watson
on 2017-08-26 21:43:31 AEST
(
hide
)
Description:
Help compiler prove that fmt_scaled snprintf fits
Filename:
MIME Type:
Creator:
Colin Watson
Created:
2017-08-26 21:43:31 AEST
Size:
983 bytes
patch
obsolete
>From ddf6c7426cbc82641d235559f16c8b38f2e8e670 Mon Sep 17 00:00:00 2001 >From: Colin Watson <cjwatson@debian.org> >Date: Sat, 26 Aug 2017 12:41:33 +0100 >Subject: [PATCH] Help compiler prove that fmt_scaled snprintf fits > >--- > openbsd-compat/fmt_scaled.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > >diff --git a/openbsd-compat/fmt_scaled.c b/openbsd-compat/fmt_scaled.c >index 7c5193e..d7f316f 100644 >--- a/openbsd-compat/fmt_scaled.c >+++ b/openbsd-compat/fmt_scaled.c >@@ -42,6 +42,7 @@ > > #ifndef HAVE_FMT_SCALED > >+#include <assert.h> > #include <stdio.h> > #include <stdlib.h> > #include <errno.h> >@@ -246,13 +247,14 @@ fmt_scaled(long long number, char *result) > > fract = (10 * fract + 512) / 1024; > /* if the result would be >= 10, round main number */ >- if (fract == 10) { >+ if (fract >= 10) { > if (number >= 0) > number++; > else > number--; > fract = 0; > } >+ assert(fract >= 0); > > if (number == 0) > strlcpy(result, "0B", FMT_SCALED_STRSIZE); >-- >2.7.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 2769
:
3042
|
3141