WinRAR's File Name Length Bug

 


Summary

In WinRAR v3.10, the length of a file name can adversely effect the extraction process. If the total number of characters in the directory path (i.e. c:\documents and settings\user\...) and the filename (i.e. testfile.txt) exceed 260 characters, WinRAR displays a message stating that no files were found in the archive. However, the archive will extract correctly if the path or filename are less than 260 characters.


Application Description

RarSoft's WinRAR is a storage compression utility (similar to WinZip), which means that it makes files smaller for archiving purposes. You can compress single files or entire folders into as small as one tenth of their original size.


Test Design

This example demonstrates the use of Domain testing. In Domain testing, we are evaluating a function's acceptance of input by choosing representative data to enter into the data fields.

In this presentation on file name length, here are some possible equivalence classes:

The only one that will be demonstrated here is the first, file names that are extremely long. The difficulty now is in determining what are the boundaries for file name length. As a tester, we may or may not be aware of what file name length a program can handle, especially since many times it is up to the operating system (like Windows, Linux, or OSX) rather than the program we are testing.

Most current operating systems are very lenient with file names, however, so the responsibility will fall back on the programmers and testers to make sure they are handled correctly within the program. The overall limits may be set by the operating system, but that allows for countless different names for files that all need to be accounted for.

The three functions that we will be concerned with in this exercise are the 'Add', 'Extract To', and 'Test' functions.

The process of creating a compressed archive is fairly simple. First, you add a file or folder to an archive. Then, you chose your compression settings. Lastly, click 'OK' to create the archive.

To verify that the archive compressed correctly, you can ask WinRAR to test the archive. This will help ensure the integrity of the data. If there are any errors, you can locate and fix them before you delete the original files.

Finally, you can extract files out of an archive, a process called decompressing. Decompressing a file will 'expand' it to the hard drive, so that it is back in its original form and ready for use.

Let's assume that there is no documentation or resource available for us to compare against, and so we assume that WinRAR can handle file lengths as long as our operating system will allow them. This at least gives us a starting place, and focuses our testing techniques.

Domain testing is a powerful testing technique for quickly finding common faults with input handling. Rather than test thousands (or millions) of inputs, we test representatives to save time and maintain efficiency. We observe the results of a domain test by directly examining the program's reaction to the input.


Performing the Test

  1. Open Notepad and save a file like the one below, using File->Save As:
    You can save the file to the Desktop as a.dat, and then rename the file, holding down 'a' until the operating system stops you at 210 characters. This is the longest filename we can have, and therefore this is the longest filename that WinRARwould have to be able to deal with.
  2. Open WinRAR and navigate the file browser window to the Desktop, where we have saved our test file.
  3. Click once on the file to select it, and then click Add from the top horizontal menu.
  4. In the Archive Name text box, give the archive a name (e.g. test1.rar).

  5. Click OK to create the archive, and the archive will now appear on the Desktop as test1.rar.
  6. In WinRAR, click once on the archive to select it, and then click on Test in the top horizontal menu. This will verify that there are no errors with the archive.

  7. Click 'OK' on the "Test Finished" box.
  8. Click on Extract To in the top horizontal menu. Click 'OK' without changing any options (the default will simply extract the archive into a folder of the same name in the current directory).

Results/Relevance

Did you receive an error message like the one above? You may not have, as it will depend on one setting that is only found by doing this domain test. Despite the misleading message, this is actually a boundary error, but of a much larger scope than at which we were originally looking. We were worried about the length of our file names in the archive (and given our results, it would appear that this was true). This is not entirely the case, however. The actual problem is that WinRAR, while extracting a file, looks at both the length of our file and the length of the path name (or the directory) where it will be stored.

During this example, for users in Windows XP that extracted the files to the Desktop, they are actually extracting them to a very long directory, such as:

C:\Documents and Settings\Joe Smith\Desktop\aaaaaaa...aaaa.dat

WinRAR will not allow the total number of characters to exceed 260, so even though our file of 210 characters should work, it does not. If you try extracting those files into a much shorter directory, you'll find they extract normally. For example, our file would extract correctly if it were extracted to:

C:\aaaa.....aaa.dat

In addition, if the file had only been 5 or 6 characters long (or even 1 character long), but had been extracted to a long path name, than the extraction would fail in the same way. Examine the error message again and imagine you are a user who has a very important file stored in an archive (with an extremely long filename or path name), and you receive that error message. The message sounds like you will not be able to retrieve the file at all. This bug is dangerous not because it actually causes harm but more because it appears to cause harm, something that can be just as damaging.


Similar Tests/Additional Notes

Some testers also found that dangerous binary computer codes could be executed if they were placed on the end of these very long file names in WinRAR, making this a critical bug of high importance to programmers.


Configuration Notes

Testing RarSoft's WinRAR v3.10 on:


Created 31 May 2004 for the CSTER

All images and written material ©Copyright Sam Oswald 2004

This work is licensed under the Creative Commons Attribution-ShareAlike License.
To view a copy of this license, visit
http://creativecommons.org/licenses/by-sa/2.0/
or send a letter to
Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305,
USA.