net/http: ServeFile adds garbage at end of file - Stat() gets wrong size from Mac OS #24423
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
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: