bsed / gorilla

Automatically exported from code.google.com/p/gorilla
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

[PATCH] gorilla/sessions NewFilesystemStore doesn’t truncate session files #53

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I’m writing a small web-app and I noticed that during testing, I sometimes 
got the error message

"2012/09/27 15:25:50 session error: securecookie: the value could not be 
decoded"

…and my session contents were lost.

After a bit of digging, this happens when you write session contents which are 
_smaller_ than the previous contents.

It can be easily fixed by using os.O_TRUNC in func (s *FilesystemStore) 
save(session *Session) (sessions/store.go:198):

    fp, err2 := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)

Please apply this fix upstream.

Thanks!

Original issue reported on code.google.com by mstpl...@gmail.com on 27 Sep 2012 at 1:31

GoogleCodeExporter commented 9 years ago
Here’s a proper patch.

Original comment by mstpl...@gmail.com on 27 Sep 2012 at 1:34

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by rodrigo.moraes on 28 Sep 2012 at 11:36

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 15eb99e408a3.

Original comment by rodrigo.moraes on 3 Oct 2012 at 9:42