Use explicitly sized types in zipalign/ziptime
getLongLE would return a 64-bit number with the upper 32-bits set when
decoding a 32-bit number with the top bit set. Per the zip file format,
it was only expected to return a 32-bit number. Use explicitly sized
types so that we use the proper sizes and don't do any implicit
extensions.
Change-Id: I5a4304dc99ce5f8f17284d4ca3094ae115207a1e
diff --git a/tools/ziptime/ZipEntry.h b/tools/ziptime/ZipEntry.h
index beea20c..26bf596 100644
--- a/tools/ziptime/ZipEntry.h
+++ b/tools/ziptime/ZipEntry.h
@@ -23,6 +23,7 @@
#define __LIBS_ZIPENTRY_H
#include <stdlib.h>
+#include <stdint.h>
#include <stdio.h>
typedef int status_t;
@@ -49,15 +50,15 @@
* Some basic functions for raw data manipulation. "LE" means
* Little Endian.
*/
- static inline unsigned short getShortLE(const unsigned char* buf) {
+ static inline uint16_t getShortLE(const uint8_t* buf) {
return buf[0] | (buf[1] << 8);
}
- static inline unsigned long getLongLE(const unsigned char* buf) {
+ static inline uint32_t getLongLE(const uint8_t* buf) {
return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
}
- static inline void putShortLE(unsigned char* buf, short val) {
- buf[0] = (unsigned char) val;
- buf[1] = (unsigned char) (val >> 8);
+ static inline void putShortLE(uint8_t* buf, uint16_t val) {
+ buf[0] = (uint8_t) val;
+ buf[1] = (uint8_t) (val >> 8);
}
protected:
@@ -99,7 +100,7 @@
status_t rewrite(FILE* fp);
- unsigned long mLocalHeaderRelOffset;
+ uint32_t mLocalHeaderRelOffset;
enum {
kSignature = 0x02014b50,