mirror of
https://github.com/dsoprea/go-exif.git
synced 2025-05-06 23:49:41 +00:00
ifd_enumerate: Bugfix for incorrect read semantics.
- ...to make sure we get the right number of bytes.
This commit is contained in:
parent
811286316f
commit
ab09051aaa
@ -57,10 +57,16 @@ func (ife *IfdTagEnumerator) getUint16() (value uint16, raw []byte, err error) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
raw = make([]byte, 2)
|
needBytes := 2
|
||||||
|
offset := 0
|
||||||
|
raw = make([]byte, needBytes)
|
||||||
|
|
||||||
_, err = ife.buffer.Read(raw)
|
for offset < needBytes {
|
||||||
log.PanicIf(err)
|
n, err := ife.buffer.Read(raw[offset:])
|
||||||
|
log.PanicIf(err)
|
||||||
|
|
||||||
|
offset += n
|
||||||
|
}
|
||||||
|
|
||||||
if ife.byteOrder == binary.BigEndian {
|
if ife.byteOrder == binary.BigEndian {
|
||||||
value = binary.BigEndian.Uint16(raw)
|
value = binary.BigEndian.Uint16(raw)
|
||||||
@ -81,10 +87,16 @@ func (ife *IfdTagEnumerator) getUint32() (value uint32, raw []byte, err error) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
raw = make([]byte, 4)
|
needBytes := 4
|
||||||
|
offset := 0
|
||||||
|
raw = make([]byte, needBytes)
|
||||||
|
|
||||||
_, err = ife.buffer.Read(raw)
|
for offset < needBytes {
|
||||||
log.PanicIf(err)
|
n, err := ife.buffer.Read(raw[offset:])
|
||||||
|
log.PanicIf(err)
|
||||||
|
|
||||||
|
offset += n
|
||||||
|
}
|
||||||
|
|
||||||
if ife.byteOrder == binary.BigEndian {
|
if ife.byteOrder == binary.BigEndian {
|
||||||
value = binary.BigEndian.Uint32(raw)
|
value = binary.BigEndian.Uint32(raw)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user