Commit 9f0ad0f4 authored by Bas Zoetekouw's avatar Bas Zoetekouw

fix kfreebsd build

parent 2c8fc28c
blktrace (1.2.0-4) unstable; urgency=low
* Split and adjust gcc warnings patch
-- Bas Zoetekouw <bas@debian.org> Wed, 13 Feb 2019 22:19:54 +0100
blktrace (1.2.0-3) unstable; urgency=low
* d/copyright: Change Format URL to correct one
......
Fix possibel buffer overflow
Patch was sent upstream to Jens Axboe <axboe@kernel.dk> on 2019-02-12
Index: blktrace-1.2.0/btt/devs.c
===================================================================
--- blktrace-1.2.0.orig/btt/devs.c
+++ blktrace-1.2.0/btt/devs.c
@@ -108,9 +108,9 @@ void dip_exit(void)
static inline FILE *open_pit(struct d_info *dip)
{
FILE *fp;
- char str[256];
+ char str[sizeof(dip->dip_name)+8]; /* "_pit.dat" is 8 chars */
- sprintf(str, "%s_pit.dat", dip->dip_name);
+ snprintf(str, sizeof(str), "%s_pit.dat", dip->dip_name);
if ((fp = my_fopen(str, "w")) == NULL)
perror(str);
......@@ -4,19 +4,6 @@ Index: blktrace-1.2.0/jhash.h
===================================================================
--- blktrace-1.2.0.orig/jhash.h
+++ blktrace-1.2.0/jhash.h
@@ -23,6 +23,12 @@
* any bugs present are my fault. Jozsef
*/
+#if defined(__GNUC__) && __GNUC__ >= 7
+ #define FALL_THROUGH __attribute__ ((fallthrough))
+#else
+ #define FALL_THROUGH ((void)0)
+#endif /* __GNUC__ >= 7 */
+
#define __rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
/* __jhash_mix - mix 3 32-bit values reversibly. */
@@ -76,19 +82,19 @@ static inline u32 jhash(const void *key,
/* last block: affect all 32 bits of (c) */
/* all the case statements fall through */
......@@ -32,36 +19,20 @@ Index: blktrace-1.2.0/jhash.h
- case 4 : a += (u32)k[3]<<24;
- case 3 : a += (u32)k[2]<<16;
- case 2 : a += (u32)k[1]<<8;
+ case 12: c += (u32)k[11]<<24; FALL_THROUGH;
+ case 11: c += (u32)k[10]<<16; FALL_THROUGH;
+ case 10: c += (u32)k[9]<<8; FALL_THROUGH;
+ case 9 : c += k[8]; FALL_THROUGH;
+ case 8 : b += (u32)k[7]<<24; FALL_THROUGH;
+ case 7 : b += (u32)k[6]<<16; FALL_THROUGH;
+ case 6 : b += (u32)k[5]<<8; FALL_THROUGH;
+ case 5 : b += k[4]; FALL_THROUGH;
+ case 4 : a += (u32)k[3]<<24; FALL_THROUGH;
+ case 3 : a += (u32)k[2]<<16; FALL_THROUGH;
+ case 2 : a += (u32)k[1]<<8; FALL_THROUGH;
+ case 12: c += (u32)k[11]<<24; /* FALLTHROUGH */
+ case 11: c += (u32)k[10]<<16; /* FALLTHROUGH */
+ case 10: c += (u32)k[9]<<8; /* FALLTHROUGH */
+ case 9 : c += k[8]; /* FALLTHROUGH */
+ case 8 : b += (u32)k[7]<<24; /* FALLTHROUGH */
+ case 7 : b += (u32)k[6]<<16; /* FALLTHROUGH */
+ case 6 : b += (u32)k[5]<<8; /* FALLTHROUGH */
+ case 5 : b += k[4]; /* FALLTHROUGH */
+ case 4 : a += (u32)k[3]<<24; /* FALLTHROUGH */
+ case 3 : a += (u32)k[2]<<16; /* FALLTHROUGH */
+ case 2 : a += (u32)k[1]<<8; /* FALLTHROUGH */
case 1 : a += k[0];
- __jhash_final(a, b, c);
+ __jhash_final(a, b, c); FALL_THROUGH;
+ __jhash_final(a, b, c); /* FALLTHROUGH */
case 0 :
break;
}
Index: blktrace-1.2.0/btt/devs.c
===================================================================
--- blktrace-1.2.0.orig/btt/devs.c
+++ blktrace-1.2.0/btt/devs.c
@@ -108,9 +108,9 @@ void dip_exit(void)
static inline FILE *open_pit(struct d_info *dip)
{
FILE *fp;
- char str[256];
+ char str[sizeof(dip->dip_name)+8]; /* "_pit.dat" is 8 chars */
- sprintf(str, "%s_pit.dat", dip->dip_name);
+ snprintf(str, sizeof(str), "%s_pit.dat", dip->dip_name);
if ((fp = my_fopen(str, "w")) == NULL)
perror(str);
......@@ -5,4 +5,5 @@ procnum.patch
spelling.patch
cve-2018-10689
python3-support.patch
gcc_warnings.patch
11_buffer_overflow.patch
12_gcc_warnings.patch
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment