ffvpx snprintf strict format check error. draft
authorISHIKAWA, Chiaki <ishikawa@yk.rim.or.jp>
Sat, 09 Nov 2019 11:00:39 +0900
changeset 81084 0b813bcef405d04034e141d32c9ea54e4df0ed59
parent 81083 55623f80ea7a85be826669e1be306a30ea104402
child 81085 da244c1a4acf98ce3cead0fc327688b7ad30acdb
push id9744
push userishikawa@yk.rim.or.jp
push dateSat, 09 Nov 2019 02:01:06 +0000
treeherdertry-comm-central@56c83244ac0e [default view] [failures only]
ffvpx snprintf strict format check error.
mozilla-M-C-022-gcc-v8-format-check-snprintef-buffer-size.patch
new file mode 100644
--- /dev/null
+++ b/mozilla-M-C-022-gcc-v8-format-check-snprintef-buffer-size.patch
@@ -0,0 +1,168 @@
+# HG changeset patch
+# User ISHIKAWA, Chiaki <ishikawa@yk.rim.or.jp>
+# Parent  04f7a782a8a4e0e2c76a183706568db0961270d5
+ffvpx snprintf strict format check error.
+
+Actually benign, but GCC-8 is evaluating the width of integer output a
+bit too wide.
+
+/NREF-COMM-CENTRAL/mozilla/media/ffvpx/libavutil/timecode.c:103:64: error: __builtin___snprintf_chk  output may be truncated before the last format character [-Werror=format-truncation=]
+     snprintf(buf, AV_TIMECODE_STR_SIZE, "%s%02d:%02d:%02d%c%02d",
+                                                                ^
+In file included from /usr/include/stdio.h:873,
+                 from /NREF-COMM-CENTRAL/mozilla/media/ffvpx/libavutil/common.h:38,
+                 from /NREF-COMM-CENTRAL/mozilla/media/ffvpx/libavutil/avutil.h:296,
+                 from /NREF-COMM-CENTRAL/mozilla/media/ffvpx/libavutil/log.h:25,
+                 from /NREF-COMM-CENTRAL/mozilla/media/ffvpx/libavutil_visibility.h:26,
+                 from <command-line>:
+/usr/include/x86_64-linux-gnu/bits/stdio2.h:67:10: note: __builtin___snprintf_chk output between 12 and 33 bytes into a destination of size 23
+   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
+          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+        __bos (__s), __fmt, __va_arg_pack ());
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+diff --git a/media/ffvpx/libavutil/timecode.c b/media/ffvpx/libavutil/timecode.c
+--- a/media/ffvpx/libavutil/timecode.c
++++ b/media/ffvpx/libavutil/timecode.c
+@@ -81,33 +81,35 @@ uint32_t av_timecode_get_smpte_from_fram
+            (hh % 10);        // units of hours
+ }
+ 
+ char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum)
+ {
+     int fps = tc->fps;
+     int drop = tc->flags & AV_TIMECODE_FLAG_DROPFRAME;
+     int hh, mm, ss, ff, neg = 0;
++    char buf2[AV_TIMECODE_STR_SIZE+20];
+ 
+     framenum += tc->start;
+     if (drop)
+         framenum = av_timecode_adjust_ntsc_framenum2(framenum, fps);
+     if (framenum < 0) {
+         framenum = -framenum;
+         neg = tc->flags & AV_TIMECODE_FLAG_ALLOWNEGATIVE;
+     }
+     ff = framenum % fps;
+     ss = framenum / fps        % 60;
+     mm = framenum / (fps*60)   % 60;
+     hh = framenum / (fps*3600);
+     if (tc->flags & AV_TIMECODE_FLAG_24HOURSMAX)
+         hh = hh % 24;
+-    snprintf(buf, AV_TIMECODE_STR_SIZE, "%s%02d:%02d:%02d%c%02d",
++    snprintf(buf2, AV_TIMECODE_STR_SIZE + 20, "%s%02d:%02d:%02d%c%02d",
+              neg ? "-" : "",
+              hh, mm, ss, drop ? ';' : ':', ff);
++    strncpy(buf, buf2, AV_TIMECODE_STR_SIZE);
+     return buf;
+ }
+ 
+ static unsigned bcd2uint(uint8_t bcd)
+ {
+    unsigned low  = bcd & 0xf;
+    unsigned high = bcd >> 4;
+    if (low > 9 || high > 9)
+diff --git a/netwerk/base/nsNetUtil.cpp b/netwerk/base/nsNetUtil.cpp
+--- a/netwerk/base/nsNetUtil.cpp
++++ b/netwerk/base/nsNetUtil.cpp
+@@ -1247,16 +1247,22 @@ nsresult NS_NewLocalFileStream(nsIFileSt
+   }
+   return rv;
+ }
+ 
+ nsresult NS_NewBufferedOutputStream(
+     nsIOutputStream** aResult, already_AddRefed<nsIOutputStream> aOutputStream,
+     uint32_t aBufferSize) {
+   nsCOMPtr<nsIOutputStream> outputStream = std::move(aOutputStream);
++#ifdef DEBUG 
++  {
++    fprintf(stderr,"NS_NewBufferedOutputStream: outputStream (= std::move(aOutputputStream)) =%p\n", (void *) outputStream);
++  }
++#endif
++  MOZ_ASSERT(outputStream);
+ 
+   nsresult rv;
+   nsCOMPtr<nsIBufferedOutputStream> out =
+       do_CreateInstance(NS_BUFFEREDOUTPUTSTREAM_CONTRACTID, &rv);
+   if (NS_SUCCEEDED(rv)) {
+     rv = out->Init(outputStream, aBufferSize);
+     if (NS_SUCCEEDED(rv)) {
+       out.forget(aResult);
+diff --git a/security/manager/ssl/tests/gtest/OCSPCacheTest.cpp b/security/manager/ssl/tests/gtest/OCSPCacheTest.cpp
+--- a/security/manager/ssl/tests/gtest/OCSPCacheTest.cpp
++++ b/security/manager/ssl/tests/gtest/OCSPCacheTest.cpp
+@@ -75,17 +75,17 @@ TEST_F(psm_OCSPCacheTest, TestPutAndGet)
+   Time timeOut(Time::uninitialized);
+   ASSERT_FALSE(cache.Get(CertID(fakeIssuer1, fakeKey001, fakeSerial000),
+                          OriginAttributes(), resultOut, timeOut));
+ }
+ 
+ TEST_F(psm_OCSPCacheTest, TestVariousGets) {
+   SCOPED_TRACE("");
+   for (int i = 0; i < MaxCacheEntries; i++) {
+-    uint8_t serialBuf[8];
++    uint8_t serialBuf[12]; // GCC 8 complained that serialBuf[8] is too narrow.
+     snprintf(mozilla::BitwiseCast<char*, uint8_t*>(serialBuf),
+              sizeof(serialBuf), "%04d", i);
+     Input fakeSerial;
+     ASSERT_EQ(Success, fakeSerial.Init(serialBuf, 4));
+     Time timeIn(now);
+     ASSERT_EQ(Success, timeIn.AddSeconds(i));
+     PutAndGet(cache, CertID(fakeIssuer1, fakeKey000, fakeSerial), Success,
+               timeIn);
+@@ -124,17 +124,17 @@ TEST_F(psm_OCSPCacheTest, TestVariousGet
+                          OriginAttributes(), resultOut, timeOut));
+ }
+ 
+ TEST_F(psm_OCSPCacheTest, TestEviction) {
+   SCOPED_TRACE("");
+   // By putting more distinct entries in the cache than it can hold,
+   // we cause the least recently used entry to be evicted.
+   for (int i = 0; i < MaxCacheEntries + 1; i++) {
+-    uint8_t serialBuf[8];
++    uint8_t serialBuf[20]; // GCC 8 complained that serialBuf[8] is too narrow.
+     snprintf(mozilla::BitwiseCast<char*, uint8_t*>(serialBuf),
+              sizeof(serialBuf), "%04d", i);
+     Input fakeSerial;
+     ASSERT_EQ(Success, fakeSerial.Init(serialBuf, 4));
+     Time timeIn(now);
+     ASSERT_EQ(Success, timeIn.AddSeconds(i));
+     PutAndGet(cache, CertID(fakeIssuer1, fakeKey000, fakeSerial), Success,
+               timeIn);
+@@ -149,17 +149,17 @@ TEST_F(psm_OCSPCacheTest, TestEviction) 
+ TEST_F(psm_OCSPCacheTest, TestNoEvictionForRevokedResponses) {
+   SCOPED_TRACE("");
+   CertID notEvicted(fakeIssuer1, fakeKey000, fakeSerial0000);
+   Time timeIn(now);
+   PutAndGet(cache, notEvicted, Result::ERROR_REVOKED_CERTIFICATE, timeIn);
+   // By putting more distinct entries in the cache than it can hold,
+   // we cause the least recently used entry that isn't revoked to be evicted.
+   for (int i = 1; i < MaxCacheEntries + 1; i++) {
+-    uint8_t serialBuf[8];
++    uint8_t serialBuf[12]; // GCC 8 complained that serialBuf[8] is too narrow.
+     snprintf(mozilla::BitwiseCast<char*, uint8_t*>(serialBuf),
+              sizeof(serialBuf), "%04d", i);
+     Input fakeSerial;
+     ASSERT_EQ(Success, fakeSerial.Init(serialBuf, 4));
+     Time timeIn(now);
+     ASSERT_EQ(Success, timeIn.AddSeconds(i));
+     PutAndGet(cache, CertID(fakeIssuer1, fakeKey000, fakeSerial), Success,
+               timeIn);
+@@ -175,17 +175,17 @@ TEST_F(psm_OCSPCacheTest, TestNoEviction
+   ASSERT_FALSE(cache.Get(evicted, OriginAttributes(), resultOut, timeOut));
+ }
+ 
+ TEST_F(psm_OCSPCacheTest, TestEverythingIsRevoked) {
+   SCOPED_TRACE("");
+   Time timeIn(now);
+   // Fill up the cache with revoked responses.
+   for (int i = 0; i < MaxCacheEntries; i++) {
+-    uint8_t serialBuf[8];
++    uint8_t serialBuf[20]; // GCC 8 complained that serialBuf[8] is too narrow.
+     snprintf(mozilla::BitwiseCast<char*, uint8_t*>(serialBuf),
+              sizeof(serialBuf), "%04d", i);
+     Input fakeSerial;
+     ASSERT_EQ(Success, fakeSerial.Init(serialBuf, 4));
+     Time timeIn(now);
+     ASSERT_EQ(Success, timeIn.AddSeconds(i));
+     PutAndGet(cache, CertID(fakeIssuer1, fakeKey000, fakeSerial),
+               Result::ERROR_REVOKED_CERTIFICATE, timeIn);