wdlkmpx / unace

The unace utility (written in C) is used for extracting, testing and viewing the contents of archives created with the ACE archiver.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Small Bug in unace1

RobK88 opened this issue · comments

There is a small bug in unace1.

If you extract a file from a version 1 ace archive that already exists and you enter C for cancel when asked whether you want to overwrite the file, it shows an error. See below.

$ unace1 e onefile.ace 
UNACE v1.3b    public version

Processing archive: onefile.ace

Authenticity Verification:
created on 29.5.2021 by *UNREGISTERED VERSION*


CHANGES.LOG
 Overwrite existing file? (Yes,Always,No,Cancel) c
Cancel
 Analyzing
Error occurred

P.S. I am unable to post a bug report for unace1 on your unace1 web page since your unace1 repo is read only. So I posted it here.

Here is the fix for the small bug in unace1:

Delete or comment out the line f_err = ERR_USER; in uac.c
P.S. if i==3 then the user entered C for Cancel when prompted to overwrite an existing file.

if (!f_ovrall)
         {
            i = wrask("Overwrite existing file?");  // prompt for overwrite
            f_ovrall = (i == 1);
            if (i == 3)
               // f_err = ERR_USER;
               return NULL;
         }

Here is a better fix.

Do NOT remove f_err = ERR_USER; from the create_dest_file() function in uac.c.

Just change if (f_err) to if (f_err && (f_err != ERR_USER)) in unace.c

         fclose (archive_fp);
         if (f_err && (f_err != ERR_USER))
         {
            printf("\nError occurred\n");
            if (f_criterr)
               printf("Critical error on drive %c\n", f_criterr);
         }

If you want to skip the Analyze phase when the end-user selects "Cancel", I would also change if (test || adat.solto) to if ((test || adat.sol) && (f_err != ERR_USER)) as follows:

            {
               if ((test || adat.sol) && (f_err != ERR_USER))
                  analyze_file();        // analyze file
            }

I reenabled the unace1 repo, you might want to open a PR or commit directly if you accept the invitation I sent hours ago

I just submitted the Pull Request where I fixed the small bug in Version 1.3b and where I added two new command line options to unace1:

 -o   Overwrite existing file(s)
 -n   Never overwrite existing file(s)

The -o option is really the same as the existing -y option. But I needed to add the -n option for my simple GUI for unace 1 for the Mac that I am working on.