summaryrefslogtreecommitdiff
path: root/src/pkg/compress/gzip/gzip.go
diff options
context:
space:
mode:
authorNigel Tao <nigeltao@golang.org>2010-01-30 12:21:51 +1100
committerNigel Tao <nigeltao@golang.org>2010-01-30 12:21:51 +1100
commitfe8b427f2f40b5bdce54bf4c17aca70fb20ae33b (patch)
treefbf721088dcc8af6be550162a0b27be30899e9e0 /src/pkg/compress/gzip/gzip.go
parentd58b3781ec517269fb54ae2d6d3d32eabba8c91d (diff)
downloadgolang-fe8b427f2f40b5bdce54bf4c17aca70fb20ae33b.tar.gz
Check gzip strings for NUL elements, since they are NUL-terminated
on the wire. R=rsc CC=golang-dev http://codereview.appspot.com/194146
Diffstat (limited to 'src/pkg/compress/gzip/gzip.go')
-rw-r--r--src/pkg/compress/gzip/gzip.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/pkg/compress/gzip/gzip.go b/src/pkg/compress/gzip/gzip.go
index c17e6e7e0..7ce0e8cd2 100644
--- a/src/pkg/compress/gzip/gzip.go
+++ b/src/pkg/compress/gzip/gzip.go
@@ -85,11 +85,11 @@ func (z *Deflater) writeBytes(b []byte) os.Error {
// writeString writes a string (in ISO 8859-1 (Latin-1) format) to z.w.
func (z *Deflater) writeString(s string) os.Error {
- // GZIP (RFC 1952) specifies that strings are null-terminated ISO 8859-1 (Latin-1).
+ // GZIP (RFC 1952) specifies that strings are NUL-terminated ISO 8859-1 (Latin-1).
// TODO(nigeltao): Convert from UTF-8 to ISO 8859-1 (Latin-1).
for _, v := range s {
- if v > 0x7f {
- return os.NewError("gzip.Write: Comment/Name character code was outside the 0x00-0x7f range")
+ if v == 0 || v > 0x7f {
+ return os.NewError("gzip.Write: non-ASCII header string")
}
}
_, err := io.WriteString(z.w, s)