projects
/
gogopherd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
00c645e
)
* Fixed partially initialized buffer bug in content type detection for short files.
author
Urban Wallasch
<urban.wallasch@freenet.de>
Thu, 4 Apr 2019 15:52:24 +0000
(17:52 +0200)
committer
Urban Wallasch
<urban.wallasch@freenet.de>
Thu, 4 Apr 2019 15:52:24 +0000
(17:52 +0200)
gogopherd.go
patch
|
blob
|
history
diff --git
a/gogopherd.go
b/gogopherd.go
index 934ce7c0d90d9fd578e29673fddeb90851c98176..14feca4469fbe8341be5efaff945a8ebd72b37be 100644
(file)
--- a/
gogopherd.go
+++ b/
gogopherd.go
@@
-130,10
+130,11
@@
func guessFiletype(path string) (string, error) {
defer f.Close()
// Get the content
buffer := make([]byte, 512)
-
_, err
= f.Read(buffer)
+
n, err :
= f.Read(buffer)
if check(err, "Read "+path) != nil {
return "i", err
}
+ buffer = buffer[:n]
contentType := http.DetectContentType(buffer)
//tracer.Print("Content Type " + path + " == "+ contentType)
shortType := strings.Split(contentType, ";")[0]