dropbear: avoid compiler optimization in m_burn
authorKonstantin Demin <[email protected]>
Tue, 16 Oct 2018 13:31:47 +0000 (16:31 +0300)
committerHans Dedecker <[email protected]>
Thu, 8 Nov 2018 10:07:05 +0000 (11:07 +0100)
cherry-pick upstream commits
 - b17254925ddd82aa633ca8128751b93840fabc9b
 - 8a4f7fe4f8435b9551c4145f93876e11de78cdcb
 - 257bba00ac1c1461b18ff1f5d420ec83fa13a368

Signed-off-by: Konstantin Demin <[email protected]>
package/network/services/dropbear/patches/016-m_burn-avoid_optimization.patch [new file with mode: 0644]

diff --git a/package/network/services/dropbear/patches/016-m_burn-avoid_optimization.patch b/package/network/services/dropbear/patches/016-m_burn-avoid_optimization.patch
new file mode 100644 (file)
index 0000000..f43528f
--- /dev/null
@@ -0,0 +1,21 @@
+--- a/dbhelpers.c
++++ b/dbhelpers.c
+@@ -9,16 +9,8 @@ void m_burn(void *data, unsigned int len
+ #elif defined(HAVE_EXPLICIT_BZERO)
+       explicit_bzero(data, len);
+ #else
+-/* Based on the method in David Wheeler's
+- * "Secure Programming for Linux and Unix HOWTO". May not be safe
+- * against link-time optimisation. */
+-      volatile char *p = data;
+-
+-      if (data == NULL)
+-              return;
+-      while (len--) {
+-              *p++ = 0x0;
+-      }
++      volatile void *p = data;
++      memset((void*)p, 0x0, len);
+ #endif
+ }