FLTK logo

[fltk/fltk] fl_filename_absolute does not correctly handle lone ".." : Windows or Unix (#142)

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

[fltk/fltk] fl_filename_absolute does not correctly handle lone ".." : Windows or Unix (#142) Kevin Routley Sep 17, 2020  
 

Windows 10 / FLTK 1.4 / Built locally with Microsoft Visual Studio 2019

Here is a sample:

    // verify our working directory is "e:/temp"
    char buff[100];
    char* cwd = fl_getcwd(buff, sizeof(buff));
    assert(!strcmp(cwd, "E:\\temp"));

    // This fails: the result is "E:/temp/.."
    fl_filename_absolute(buff, sizeof(buff), "..");
    assert(!strcmp(buff, "E:/");

The problem is that the loop logic in filename_absolute fails to account for a ".." with no following directory separator.

Changing this line:
if (start[1]=='.' && isdirsep(start[2])) {
to this:
if (start[1] == '.' && (isdirsep(start[2]) || !start[2])) {
gives the correct results.

I've tested this on Windows but looking at the code in filename_absolute.cxx, the problem will occur there as well.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

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