Menu

#105 [lbreakout2] lbreakout2 crashes when being compiled with -D_FORTIFY_SOURCE=3

None
closed-rejected
None
5
2024-01-13
2024-01-06
Thomas Huth
No

breakout2 crashes during startup when it has been compiled with -D_FORTIFY_SOURCE=3 .
Looking at a backtrace shows that the crash happens in the vsnprintf() line in stk_surface_load() in gui/stk.c :

https://sourceforge.net/p/lgames/code/612/tree/trunk/lbreakout2/gui/stk.c#l648

I think the "path-ptr" part here is wrong, it should be "ptr - path" instead. The following patch fixes the issue:

diff -u gui/stk.c.orig gui/stk.c
--- gui/stk.c.orig  2024-01-06 11:07:35.209249556 +0100
+++ gui/stk.c   2024-01-06 11:07:46.784327417 +0100
@@ -645,7 +645,7 @@
          ptr = path + strlen( path );
     }
     va_start( args, format );
-    vsnprintf( ptr, 511 - (path-ptr), format, args );
+    vsnprintf( ptr, sizeof(path) - (ptr - path), format, args );
     va_end( args );
 #ifdef STK_DEBUG
     printf( "loading %s\n", path );

Discussion

  • Michael Speck

    Michael Speck - 2024-01-13
    • status: open --> closed-rejected
    • Group: -->
     
  • Michael Speck

    Michael Speck - 2024-01-13

    lbreakout2 is no longer maintained, lbreakouthd is the current "version"

     

Log in to post a comment.