open-watcom / open-watcom-v2

Open Watcom V2.0 - Source code repository, Wiki, Latest Binary build, Archived builds including all installers for download.
Other
992 stars 163 forks source link

whelp: Avoid a crash, when the search path has an empty segment #1312

Closed winspool closed 3 months ago

winspool commented 4 months ago

The double colon in $PATH let whelp segfault, when whelp is searching for available help files.

-- Regards ... Detlef

jmalak commented 3 months ago

The fix should provide a transition to processing the next segment if the segment is empty. The proposed fix only fixes the crash, not the bug in the algorithm that caused the problem.

jmalak commented 3 months ago

What about following solution

        if( *p != '\0' ) {
            strcpy( buf, p );
            len = strlen( buf ) - 1;
#ifdef __UNIX__
            if( buf[len] == '/' )
                buf[len] = '\0';
#else
            if( buf[len] == '/' || buf[len] == '\\' )
                buf[len] = '\0';
#endif
            list = scanDirectory( buf, list );
        }
jmalak commented 3 months ago

fixed correctly in git repository