File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -606,13 +606,22 @@ int main(int argc, char *argv[]) {
606606 int length ;
607607 char fullpath [PATH_MAX ];
608608
609- if (getenv ("TARGET_APPIMAGE" ) == NULL ){
609+ if (getenv ("TARGET_APPIMAGE" ) == NULL ) {
610610 // If we are operating on this file itself
611- length = readlink (appimage_path , fullpath , sizeof (fullpath ));
612- fullpath [length ] = '\0' ;
611+ ssize_t len = readlink (appimage_path , fullpath , sizeof (fullpath ));
612+ if (len < 0 ) {
613+ perror ("Failed to obtain absolute path" );
614+ exit (EXIT_EXECERROR );
615+ }
616+ fullpath [len ] = '\0' ;
613617 } else {
614- // If we are operating on a different AppImage than this file
615- sprintf (fullpath , "%s" , appimage_path ); // TODO: Make absolute
618+ char * abspath = realpath (appimage_path , NULL );
619+ if (abspath == NULL ) {
620+ perror ("Failed to obtain absolute path" );
621+ exit (EXIT_EXECERROR );
622+ }
623+ strcpy (fullpath , abspath );
624+ free (abspath );
616625 }
617626
618627 if (arg && strcmp (arg , "appimage-extract-and-run" ) == 0 ) {
You can’t perform that action at this time.
0 commit comments