(parent *os.Root, name, displayPath string)
| 356 | } |
| 357 | |
| 358 | func (r *Root) openVerifiedDirectory(parent *os.Root, name, displayPath string) (*os.Root, error) { |
| 359 | before, err := parent.Lstat(name) |
| 360 | if err != nil { |
| 361 | return nil, err |
| 362 | } |
| 363 | redirect, err := isPathRedirect(r, parent, name, before) |
| 364 | if err != nil { |
| 365 | return nil, err |
| 366 | } |
| 367 | if redirect { |
| 368 | return nil, SymlinkTraversalError{Path: displayPath} |
| 369 | } |
| 370 | |
| 371 | root, err := r.openRoot(parent, name) |
| 372 | if err != nil { |
| 373 | return nil, err |
| 374 | } |
| 375 | opened, err := root.Stat(".") |
| 376 | if err != nil { |
| 377 | _ = root.Close() |
| 378 | return nil, err |
| 379 | } |
| 380 | after, err := parent.Lstat(name) |
| 381 | if err != nil { |
| 382 | _ = root.Close() |
| 383 | return nil, err |
| 384 | } |
| 385 | redirect, err = isPathRedirect(r, parent, name, after) |
| 386 | if err != nil { |
| 387 | _ = root.Close() |
| 388 | return nil, err |
| 389 | } |
| 390 | if redirect { |
| 391 | _ = root.Close() |
| 392 | return nil, SymlinkTraversalError{Path: displayPath} |
| 393 | } |
| 394 | if !os.SameFile(before, opened) || !os.SameFile(before, after) { |
| 395 | _ = root.Close() |
| 396 | return nil, fmt.Errorf("directory %q changed while opening", displayPath) |
| 397 | } |
| 398 | return root, nil |
| 399 | } |
| 400 | |
| 401 | func (r *Root) openVerifiedEntry(parent *os.Root, name, displayPath string) (*os.File, error) { |
| 402 | before, err := parent.Lstat(name) |
no test coverage detected