FLTK logo

[branch-1.4] 72b084c - Backport 74b0dc7

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Library      Forums      Links      Apps     Login 
[  All Forums  |  Back to fltk.commit  ]
 
[ Previous Message ] [ Next Message ]

[branch-1.4] 72b084c - Backport 74b0dc7 "Matthias Melcher" Jul 16, 2025  
 
commit 72b084c6acaac9b9ba07ed4525755e4c10783910
Author:     Matthias Melcher <github@matthiasm.com>
AuthorDate: Wed Jul 16 11:50:35 2025 +0200
Commit:     Matthias Melcher <github@matthiasm.com>
CommitDate: Wed Jul 16 11:50:35 2025 +0200

    Backport 74b0dc7
    
    Fix address sanitizer exception for macOS native file chooser
    
    The `memcmp` call would crash in Adress sanitizer if the memory compare
    would run into an undefined buffer. `memcmp` is not guaranteed to stop
    reading a buffer if a difference is found.

 src/Fl_Native_File_Chooser_MAC.mm | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git src/Fl_Native_File_Chooser_MAC.mm src/Fl_Native_File_Chooser_MAC.mm
index 77cf165..8bb74e0 100644
--- src/Fl_Native_File_Chooser_MAC.mm
+++ src/Fl_Native_File_Chooser_MAC.mm
@@ -417,9 +417,12 @@ int Fl_Quartz_Native_File_Chooser_Driver::get_saveas_basename(void) {
     const char *d = [[[[_panel URL] path] stringByDeletingLastPathComponent] UTF8String];
     int l = (int)strlen(d) + 1;
     if (strcmp(d, "/") == 0) l = 1;
-    int lu = strlen(UNLIKELYPREFIX);
-    // Remove UNLIKELYPREFIX between directory and filename parts
-    if (memcmp(q+l, UNLIKELYPREFIX, lu) == 0) memmove(q + l, q + l + lu, strlen(q + l + lu) + 1);
+    int lu = (int)strlen(UNLIKELYPREFIX);
+    int ln = (int)strlen(q+l);
+    if (ln >= lu) {
+      // Remove UNLIKELYPREFIX between directory and filename parts
+      if (memcmp(q+l, UNLIKELYPREFIX, lu) == 0) memmove(q + l, q + l + lu, strlen(q + l + lu) + 1);
+    }
   }
   set_single_pathname( q );
   free(q);
[ Direct Link to Message ]
 
     
[ Previous Message ] [ Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2026 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.