Skip to content

Commit de38ba1

Browse files
ForestEckhardtryanmoran
authored andcommitted
Just trying to make CodeQL happy
1 parent 998f68d commit de38ba1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

vacation/vacation.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ func (ta TarArchive) Decompress(destination string) error {
9393
return fmt.Errorf("failed to read tar response: %s", err)
9494
}
9595

96+
// Skip if the destination it the destination directory itself i.e. ./
97+
if hdr.Name == "."+string(filepath.Separator) {
98+
continue
99+
}
100+
96101
err = checkExtractPath(hdr.Name, destination)
97102
if err != nil {
98103
return err
@@ -328,6 +333,11 @@ func (z ZipArchive) Decompress(destination string) error {
328333
}
329334

330335
for _, f := range zr.File {
336+
// Skip if the destination it the destination directory itself i.e. ./
337+
if f.Name == "."+string(filepath.Separator) {
338+
continue
339+
}
340+
331341
err = checkExtractPath(f.Name, destination)
332342
if err != nil {
333343
return err
@@ -409,12 +419,8 @@ func (z ZipArchive) Decompress(destination string) error {
409419
}
410420

411421
// This function checks to see that the given path is within the destination
412-
// directory or it is the destination directory itself i.e. ./
422+
// directory
413423
func checkExtractPath(filePath string, destination string) error {
414-
if filePath == "."+string(os.PathSeparator) {
415-
return nil
416-
}
417-
418424
destpath := filepath.Join(destination, filePath)
419425
if !strings.HasPrefix(destpath, filepath.Clean(destination)+string(os.PathSeparator)) {
420426
return fmt.Errorf("illegal file path %q: the file path does not occur within the destination directory", filePath)

0 commit comments

Comments
 (0)