net/http: ServeFile adds garbage at end of file - Stat() gets wrong size from Mac OS #24423
Labels
Milestone
Comments
can you use you file may have non-printable chars in the end does your file have some BOM / utf8 marker? is there any change to provide the original file + md5 / sha1 to look inside? |
Doing some more investigation, the hexdump seems to have repaired the file. Very odd problem. I will keep monitoring to see if I can reproduce, but now it looks like some kind of filesystem anomally and not go related. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Please answer these questions before submitting your issue. Thanks!
What did you do?
Called http.ServeFile on a javascript file with a ".js" ending in Mac OS, pointing to a file that is 40010 bytes long. This is confirmed by both counting the bytes using a text editor, and seeing the size in the Mac GetInfo window in the Finder.
What did you expect to see?
The file sent as is.
What did you see instead?
The file is sent, but 6 extra garbage bytes are tacked on to the end. Stepping in to ServeFile, the cuplrit appears to be that Stat() is showing a file size of 40016, and so ServeFile goes ahead and reports the files size in the http header as 40016, and also reads the buffer past the end of the file.
System details
This was also a problem in go 1.9.1
The text was updated successfully, but these errors were encountered: