aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/archive/zip/struct.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/archive/zip/struct.go')
-rw-r--r--libgo/go/archive/zip/struct.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/libgo/go/archive/zip/struct.go b/libgo/go/archive/zip/struct.go
index f613ebd..c90151d 100644
--- a/libgo/go/archive/zip/struct.go
+++ b/libgo/go/archive/zip/struct.go
@@ -81,8 +81,17 @@ const (
// See the zip spec for details.
type FileHeader struct {
// Name is the name of the file.
- // It must be a relative path, not start with a drive letter (e.g. C:),
- // and must use forward slashes instead of back slashes.
+ //
+ // It must be a relative path, not start with a drive letter (such as "C:"),
+ // and must use forward slashes instead of back slashes. A trailing slash
+ // indicates that this file is a directory and should have no data.
+ //
+ // When reading zip files, the Name field is populated from
+ // the zip file directly and is not validated for correctness.
+ // It is the caller's responsibility to sanitize it as
+ // appropriate, including canonicalizing slash directions,
+ // validating that paths are relative, and preventing path
+ // traversal through filenames ("../../../").
Name string
// Comment is any arbitrary user-defined string shorter than 64KiB.
@@ -201,7 +210,7 @@ func timeZone(offset time.Duration) *time.Location {
// msDosTimeToTime converts an MS-DOS date and time into a time.Time.
// The resolution is 2s.
-// See: http://msdn.microsoft.com/en-us/library/ms724247(v=VS.85).aspx
+// See: https://msdn.microsoft.com/en-us/library/ms724247(v=VS.85).aspx
func msDosTimeToTime(dosDate, dosTime uint16) time.Time {
return time.Date(
// date bits 0-4: day of month; 5-8: month; 9-15: years since 1980
@@ -221,7 +230,7 @@ func msDosTimeToTime(dosDate, dosTime uint16) time.Time {
// timeToMsDosTime converts a time.Time to an MS-DOS date and time.
// The resolution is 2s.
-// See: http://msdn.microsoft.com/en-us/library/ms724274(v=VS.85).aspx
+// See: https://msdn.microsoft.com/en-us/library/ms724274(v=VS.85).aspx
func timeToMsDosTime(t time.Time) (fDate uint16, fTime uint16) {
fDate = uint16(t.Day() + int(t.Month())<<5 + (t.Year()-1980)<<9)
fTime = uint16(t.Second()/2 + t.Minute()<<5 + t.Hour()<<11)