Skip to content
  • Roman Lebedev's avatar
    gegl-imgcmp: main: if images differ, memcpy() right amount of string · d54c292d
    Roman Lebedev authored and Mel Henning's avatar Mel Henning committed
    If one of tests fail and images are different, we write image
    difference under a new name. We use very scary looking memcpy()
    to replace last 4 symbols of filename with "-diff.png", but
    since sizeof("-diff.png") == 10, we were reading 1 byte past
    string bound.
    
    Fixes AddressSanitiser complaint like:
    ...
    PASS apply-lens3.xml (OpenCL)
    /home/lebedevri/src/_GIMP/gegl/tests/compositions/reference/bump-map.png and /home/lebedevri/src/_GIMP/gegl/tests/compositions/output/bump-map.png differ
      wrong pixels   : 46/150000 (0.03%)
      max ?e         : 0.214
      avg ?e (wrong) : 0.111(wrong) 0.000(total)
    =================================================================
    ==29799==ERROR: AddressSanitizer: global-buffer-overflow on address 0x000000402aa0 at pc 0x4020b0 bp 0x7fffa5051640 sp 0x7fffa5051638
    READ of size 11 at 0x000000402aa0 thread T0
        0 0x4020af in main /home/lebedevri/src/_GIMP/gegl/tools/gegl-imgcmp.c:148
        1 0x7fe64b509b44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)
        2 0x40154b (/home/lebedevri/src/_GIMP/gegl/tools/.libs/gegl-imgcmp+0x40154b)
    
    0x000000402aa0 is located 4205152 bytes insideASAN:SIGSEGV
    ==29799==AddressSanitizer: while reporting a bug found another one.Ignoring.
    FAIL bump-map.xml
    ...
    d54c292d