leahneukirchen / mblaze

Unix utilities to deal with Maildir
Other
445 stars 48 forks source link

mgenmid: fix off-by-one #73

Closed nmeum closed 7 years ago

nmeum commented 7 years ago

When compiling mblaze with make CFLAGS=-Os mgenid segfaults here. Inspecting the coredumb with gdb yields the following:

(gdb) bt                                                                                                                                                                 
#0  a_crash () at ./arch/x86_64/atomic_arch.h:108                                                                                                                        
#1  __stack_chk_fail () at src/env/__stack_chk_fail.c:17
#2  0x0000005b5987c61f in printb36 (x=<optimized out>) at mgenmid.c:28
#3  0x0000005b5987c3df in main () at mgenmid.c:108

After looking at the printb36 function I noticed that it seems to write outside the buffer bounds due to an off-by-one. This patch fixes this problem.

leahneukirchen commented 7 years ago

Good catch! I fixed it slightly differently.