Uwe,

Thanks for your good bug report and patch.
Can you tried the attached patch instead of yours?

Jean-Louis

On 18/02/17 06:31 PM, Uwe Menges wrote:
Hi,

Today I got a segfault from planner when I tried to run the weekly
backup on my Fedora 24 workstation:

Feb 18 12:16:26 lima audit[4905]: ANOM_ABEND auid=1000 uid=0 gid=6 ses=11 
subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 pid=4905 comm="planner" 
exe="/usr/lib64/amanda/planner" sig=11
Feb 18 12:16:26 lima kernel: planner[4905]: segfault at 0 ip 00007f20c57cd47a 
sp 00007fff62d27ae8 error 4 in libc-2.23.so[7f20c5731000+1b9000]

After some debugging efforts involving wrapping planner in valgrind, I
got that:

==27328== 1 errors in context 1 of 20:
==27328== Invalid read of size 1
==27328==    at 0x8432460: __strcmp_sse2_unaligned (in /usr/lib64/libc-2.23.so)
==27328==    by 0x65AD0B8: g_str_equal (in /usr/lib64/libglib-2.0.so.0.4800.2)
==27328==    by 0x4E54D88: nb_tape_in_storage (tapefile.c:1201)
==27328==    by 0x10EBB0: when_overwrite (planner.c:1315)
==27328==    by 0x1103AE: setup_estimate (planner.c:1024)
==27328==    by 0x10DF79: main (planner.c:633)
==27328==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

The attached patch seems to fix the segfault for me.

Yours, Uwe

diff --git a/server-src/tapefile.c b/server-src/tapefile.c
index bb06173..38173ca 100644
--- a/server-src/tapefile.c
+++ b/server-src/tapefile.c
@@ -1199,8 +1199,7 @@ nb_tape_in_storage(
     int nb_tapes = 0;
 
     for (tp = tape_list; tp != NULL; tp = tp->next) {
-	if (tp->storage &&
-	    g_str_equal(storage_name, tp->storage)) {
+	if (g_strcmp0(storage_name,tp->storage) == 0) {
 	    nb_tapes++;
 	}
     }

Reply via email to