From 8aef2bfedddb49285914612c57be3a1abe239631 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Fri, 8 Oct 2021 14:08:07 -0400 Subject: [PATCH] Fix warnings, update Xcode project. --- pdfio-crypto.c | 8 ++++---- pdfio-md5.c | 4 ++-- pdfio.xcodeproj/project.pbxproj | 14 +++++++++++++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/pdfio-crypto.c b/pdfio-crypto.c index 2a37670..e0a9a06 100644 --- a/pdfio-crypto.c +++ b/pdfio-crypto.c @@ -80,7 +80,7 @@ static const uint8_t Rcon[11] = // Round constants // Local functions... // -static void AddRoundKey(uint8_t round, state_t *state, const uint8_t *RoundKey); +static void AddRoundKey(size_t round, state_t *state, const uint8_t *RoundKey); static void SubBytes(state_t *state); static void ShiftRows(state_t *state); static uint8_t xtime(uint8_t x); @@ -252,7 +252,7 @@ _pdfioCryptoAESEncrypt( // This function adds the round key to state. // The round key is added to the state by an XOR function. static void -AddRoundKey(uint8_t round, state_t *state, const uint8_t *RoundKey) +AddRoundKey(size_t round, state_t *state, const uint8_t *RoundKey) { unsigned i; // Looping var uint8_t *sptr = (*state)[0]; // Pointer into state @@ -314,7 +314,7 @@ ShiftRows(state_t *state) static uint8_t xtime(uint8_t x) { - return ((x << 1) ^ ((x >> 7) * 0x1b)); + return ((uint8_t)((x << 1) ^ ((x >> 7) * 0x1b))); } @@ -466,7 +466,7 @@ Cipher(state_t *state, const _pdfio_aes_t *ctx) static void InvCipher(state_t *state, const _pdfio_aes_t *ctx) { - uint8_t round = 0; + size_t round; // Add the First round key to the state before starting the rounds. AddRoundKey(ctx->round_size, state, ctx->round_key); diff --git a/pdfio-md5.c b/pdfio-md5.c index 2561b35..45e1511 100644 --- a/pdfio-md5.c +++ b/pdfio-md5.c @@ -281,7 +281,7 @@ _pdfioCryptoMD5Append(_pdfio_md5_t *pms, const uint8_t *data, size_t nbytes) { const uint8_t *p = data; size_t left = nbytes; - int offset = (pms->count[0] >> 3) & 63; + size_t offset = (pms->count[0] >> 3) & 63; uint32_t nbits = (uint32_t)(nbytes << 3); if (nbytes == 0) @@ -295,7 +295,7 @@ _pdfioCryptoMD5Append(_pdfio_md5_t *pms, const uint8_t *data, size_t nbytes) /* Process an initial partial block. */ if (offset) { - int copy = (offset + nbytes > 64 ? 64 - offset : nbytes); + size_t copy = (offset + nbytes > 64 ? 64 - offset : nbytes); memcpy(pms->buf + offset, p, copy); if (offset + copy < 64) diff --git a/pdfio.xcodeproj/project.pbxproj b/pdfio.xcodeproj/project.pbxproj index a80d998..39a0005 100644 --- a/pdfio.xcodeproj/project.pbxproj +++ b/pdfio.xcodeproj/project.pbxproj @@ -26,6 +26,9 @@ 279E1036267D043B00D3A349 /* ttf.c in Sources */ = {isa = PBXBuildFile; fileRef = 279E1034267D043B00D3A349 /* ttf.c */; }; 279E103B267D04E600D3A349 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 279E103A267D04E600D3A349 /* libz.tbd */; }; 27ECBD8926419DAB0025312A /* libpdfio.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 273440B0263D6FE200FBFD63 /* libpdfio.a */; }; + 27F2F0602710BE92008ECD36 /* pdfio-md5.c in Sources */ = {isa = PBXBuildFile; fileRef = 27F2F05D2710BE92008ECD36 /* pdfio-md5.c */; }; + 27F2F0612710BE92008ECD36 /* pdfio-rc4.c in Sources */ = {isa = PBXBuildFile; fileRef = 27F2F05E2710BE92008ECD36 /* pdfio-rc4.c */; }; + 27F2F0622710BE92008ECD36 /* pdfio-crypto.c in Sources */ = {isa = PBXBuildFile; fileRef = 27F2F05F2710BE92008ECD36 /* pdfio-crypto.c */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -79,6 +82,9 @@ 279E1033267D043B00D3A349 /* ttf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ttf.h; sourceTree = ""; }; 279E1034267D043B00D3A349 /* ttf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttf.c; sourceTree = ""; }; 279E103A267D04E600D3A349 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; + 27F2F05D2710BE92008ECD36 /* pdfio-md5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "pdfio-md5.c"; sourceTree = ""; }; + 27F2F05E2710BE92008ECD36 /* pdfio-rc4.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "pdfio-rc4.c"; sourceTree = ""; }; + 27F2F05F2710BE92008ECD36 /* pdfio-crypto.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = "pdfio-crypto.c"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -153,16 +159,19 @@ 273440BA263D727800FBFD63 /* pdfio-array.c */, 273440BB263D727800FBFD63 /* pdfio-common.c */, 271EA703265B2B1000ACDD39 /* pdfio-content.c */, + 27F2F05F2710BE92008ECD36 /* pdfio-crypto.c */, 273440BE263D727800FBFD63 /* pdfio-dict.c */, 273440BD263D727800FBFD63 /* pdfio-file.c */, + 27F2F05D2710BE92008ECD36 /* pdfio-md5.c */, 273440BC263D727800FBFD63 /* pdfio-object.c */, 273440C2263D727800FBFD63 /* pdfio-page.c */, + 27F2F05E2710BE92008ECD36 /* pdfio-rc4.c */, 273440BF263D727800FBFD63 /* pdfio-stream.c */, 273440B9263D727800FBFD63 /* pdfio-string.c */, 273440E3263DD7EA00FBFD63 /* pdfio-token.c */, 273440C0263D727800FBFD63 /* pdfio-value.c */, - 279E1033267D043B00D3A349 /* ttf.h */, 279E1034267D043B00D3A349 /* ttf.c */, + 279E1033267D043B00D3A349 /* ttf.h */, ); name = Library; sourceTree = ""; @@ -281,11 +290,14 @@ 273440CB263D727800FBFD63 /* pdfio-value.c in Sources */, 273440CA263D727800FBFD63 /* pdfio-stream.c in Sources */, 273440CD263D727800FBFD63 /* pdfio-page.c in Sources */, + 27F2F0622710BE92008ECD36 /* pdfio-crypto.c in Sources */, 273440C5263D727800FBFD63 /* pdfio-array.c in Sources */, 273440E4263DD7EA00FBFD63 /* pdfio-token.c in Sources */, 273440C7263D727800FBFD63 /* pdfio-object.c in Sources */, + 27F2F0602710BE92008ECD36 /* pdfio-md5.c in Sources */, 273440C4263D727800FBFD63 /* pdfio-string.c in Sources */, 271EA705265B2B1000ACDD39 /* pdfio-content.c in Sources */, + 27F2F0612710BE92008ECD36 /* pdfio-rc4.c in Sources */, 273440C6263D727800FBFD63 /* pdfio-common.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0;