wohaph / keyczar

Automatically exported from code.google.com/p/keyczar
0 stars 0 forks source link

KeyczarTool create needs to check the location argument and append File.separator to it in main() not in KeyczarFileReader() #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

org.keyczar.KeyczarTool create --location=.\sample --purpose=crypt

What is the expected output? What do you see instead?

Expect to see a ".\sample\meta" file created, instead the file that's
created is "samplemeta"

What version of the product are you using? On what operating system?

Keyczar version: 0.5b
OS: Windows XP Pro

Please provide any additional information below.

Using the Java API.
JDK: 1.6.0_04

Current work around is to add a File.separator at the end of the location
argument and then the meta file is created correctly:

org.keyczar.KeyczarTool create --location=.\sample\ --purpose=crypt

Proposed solution:

Add the following to KeyczarTool.java main method after grabbing locationFlag:

        // Verify location is a path, not a file!
        assert(locationFlag != null);

        if (!locationFlag.endsWith(File.separator))
        {
            locationFlag += File.separator;
        }

Remove the following from KeyczarFileReader.java constructor:

    if (fileLocation != null && !fileLocation.endsWith(File.separator)) {
      fileLocation += File.separator;
    }

Original issue reported on code.google.com by epyatkev...@gmail.com on 13 Aug 2008 at 8:59

GoogleCodeExporter commented 9 years ago
Good catch! Didn't remove the check in the KeyczarFileReader constructor since 
it's
best to be safe and the check doesn't hurt. Thanks!

Original comment by arkajit.dey on 13 Aug 2008 at 10:32