richardlehane / siegfried

signature-based file format identification
http://www.itforarchivists.com/siegfried
Apache License 2.0
224 stars 30 forks source link

Size represented as signed integer in writer interface, returns minus past 3GB #59

Closed ross-spencer closed 8 years ago

ross-spencer commented 8 years ago

I'm seeing n size value 3245146112 output as -1049821184 in the DROID output.

It looks like it's because the DROID writer asks for an signed int:

func (d *droidWriter) writeFile(p string, sz int64, mod string, checksum []byte, err error, ids iterableID) 

I'm also wondering if (Itoa) can handle this type: https://golang.org/pkg/strconv/#Itoa

d.rec[7] = strconv.Itoa(int(sz)) can handle the 64-bit int type? 

I tried chasing the issue around, but it seems like the writer should receive a uint64 as input over an int64. Size should never be signed, that is, should always be zero or positive.

richardlehane commented 8 years ago

You're all issues this week!

This was a sloppy int conversion (int64 is right type, it is from https://golang.org/pkg/os/#FileInfo, I was using the wrong strconv function and downcasting the int in the process). Fixed in https://github.com/richardlehane/siegfried/commit/c653fa43c83b93e4bc4e0ee52aa3cec51bd3931c