| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ff64a24 commit 83e37e1
13 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Upgrade libexpat embedded copy from version 2.2.1 to 2.2.3 to get security | ||
| 2 | + fixes. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,7 +24,6 @@ extern "C" { | |||
| 24 | 24 | struct XML_ParserStruct; | |
| 25 | 25 | typedef struct XML_ParserStruct *XML_Parser; | |
| 26 | 26 | ||
| 27 | - /* Should this be defined using stdbool.h when C99 is available? */ | ||
| 28 | 27 | typedef unsigned char XML_Bool; | |
| 29 | 28 | #define XML_TRUE ((XML_Bool) 1) | |
| 30 | 29 | #define XML_FALSE ((XML_Bool) 0) | |
@@ -1049,7 +1048,7 @@ XML_GetFeatureList(void); | |||
| 1049 | 1048 | */ | |
| 1050 | 1049 | #define XML_MAJOR_VERSION 2 | |
| 1051 | 1050 | #define XML_MINOR_VERSION 2 | |
| 1052 | - #define XML_MICRO_VERSION 1 | ||
| 1051 | + #define XML_MICRO_VERSION 3 | ||
| 1053 | 1052 | ||
| 1054 | 1053 | #ifdef __cplusplus | |
| 1055 | 1054 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,141 @@ | |||
| 1 | + /*************************************************************************** | ||
| 2 | + * _ _ ____ _ | ||
| 3 | + * Project ___| | | | _ \| | | ||
| 4 | + * / __| | | | |_) | | | ||
| 5 | + * | (__| |_| | _ <| |___ | ||
| 6 | + * \___|\___/|_| \_\_____| | ||
| 7 | + * | ||
| 8 | + * Copyright (C) 2016 - 2017, Steve Holme, <steve_holme@hotmail.com>. | ||
| 9 | + * | ||
| 10 | + * All rights reserved. | ||
| 11 | + * | ||
| 12 | + * Permission to use, copy, modify, and distribute this software for any | ||
| 13 | + * purpose with or without fee is hereby granted, provided that the above | ||
| 14 | + * copyright notice and this permission notice appear in all copies. | ||
| 15 | + * | ||
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 17 | + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 18 | + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF | ||
| 19 | + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
| 20 | + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
| 21 | + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
| 22 | + * THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 23 | + * | ||
| 24 | + * Except as contained in this notice, the name of a copyright holder shall | ||
| 25 | + * not be used in advertising or otherwise to promote the sale, use or other | ||
| 26 | + * dealings in this Software without prior written authorization of the | ||
| 27 | + * copyright holder. | ||
| 28 | + * | ||
| 29 | + ***************************************************************************/ | ||
| 30 | + | ||
| 31 | + #if defined(_WIN32) | ||
| 32 | + | ||
| 33 | + #include <windows.h> | ||
| 34 | + #include <tchar.h> | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + HMODULE _Expat_LoadLibrary(LPCTSTR filename); | ||
| 38 | + | ||
| 39 | + | ||
| 40 | + #if !defined(LOAD_WITH_ALTERED_SEARCH_PATH) | ||
| 41 | + #define LOAD_WITH_ALTERED_SEARCH_PATH 0x00000008 | ||
| 42 | + #endif | ||
| 43 | + | ||
| 44 | + #if !defined(LOAD_LIBRARY_SEARCH_SYSTEM32) | ||
| 45 | + #define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 | ||
| 46 | + #endif | ||
| 47 | + | ||
| 48 | + /* We use our own typedef here since some headers might lack these */ | ||
| 49 | + typedef HMODULE (APIENTRY *LOADLIBRARYEX_FN)(LPCTSTR, HANDLE, DWORD); | ||
| 50 | + | ||
| 51 | + /* See function definitions in winbase.h */ | ||
| 52 | + #ifdef UNICODE | ||
| 53 | + # ifdef _WIN32_WCE | ||
| 54 | + # define LOADLIBARYEX L"LoadLibraryExW" | ||
| 55 | + # else | ||
| 56 | + # define LOADLIBARYEX "LoadLibraryExW" | ||
| 57 | + # endif | ||
| 58 | + #else | ||
| 59 | + # define LOADLIBARYEX "LoadLibraryExA" | ||
| 60 | + #endif | ||
| 61 | + | ||
| 62 | + | ||
| 63 | + /* | ||
| 64 | + * _Expat_LoadLibrary() | ||
| 65 | + * | ||
| 66 | + * This is used to dynamically load DLLs using the most secure method available | ||
| 67 | + * for the version of Windows that we are running on. | ||
| 68 | + * | ||
| 69 | + * Parameters: | ||
| 70 | + * | ||
| 71 | + * filename [in] - The filename or full path of the DLL to load. If only the | ||
| 72 | + * filename is passed then the DLL will be loaded from the | ||
| 73 | + * Windows system directory. | ||
| 74 | + * | ||
| 75 | + * Returns the handle of the module on success; otherwise NULL. | ||
| 76 | + */ | ||
| 77 | + HMODULE _Expat_LoadLibrary(LPCTSTR filename) | ||
| 78 | + { | ||
| 79 | + HMODULE hModule = NULL; | ||
| 80 | + LOADLIBRARYEX_FN pLoadLibraryEx = NULL; | ||
| 81 | + | ||
| 82 | + /* Get a handle to kernel32 so we can access it's functions at runtime */ | ||
| 83 | + HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32")); | ||
| 84 | + if(!hKernel32) | ||
| 85 | + return NULL; | ||
| 86 | + | ||
| 87 | + /* Attempt to find LoadLibraryEx() which is only available on Windows 2000 | ||
| 88 | + and above */ | ||
| 89 | + pLoadLibraryEx = (LOADLIBRARYEX_FN) GetProcAddress(hKernel32, LOADLIBARYEX); | ||
| 90 | + | ||
| 91 | + /* Detect if there's already a path in the filename and load the library if | ||
| 92 | + there is. Note: Both back slashes and forward slashes have been supported | ||
| 93 | + since the earlier days of DOS at an API level although they are not | ||
| 94 | + supported by command prompt */ | ||
| 95 | + if(_tcspbrk(filename, TEXT("\\/"))) { | ||
| 96 | + /** !checksrc! disable BANNEDFUNC 1 **/ | ||
| 97 | + hModule = pLoadLibraryEx ? | ||
| 98 | + pLoadLibraryEx(filename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) : | ||
| 99 | + LoadLibrary(filename); | ||
| 100 | + } | ||
| 101 | + /* Detect if KB2533623 is installed, as LOAD_LIBARY_SEARCH_SYSTEM32 is only | ||
| 102 | + supported on Windows Vista, Windows Server 2008, Windows 7 and Windows | ||
| 103 | + Server 2008 R2 with this patch or natively on Windows 8 and above */ | ||
| 104 | + else if(pLoadLibraryEx && GetProcAddress(hKernel32, "AddDllDirectory")) { | ||
| 105 | + /* Load the DLL from the Windows system directory */ | ||
| 106 | + hModule = pLoadLibraryEx(filename, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); | ||
| 107 | + } | ||
| 108 | + else { | ||
| 109 | + /* Attempt to get the Windows system path */ | ||
| 110 | + UINT systemdirlen = GetSystemDirectory(NULL, 0); | ||
| 111 | + if(systemdirlen) { | ||
| 112 | + /* Allocate space for the full DLL path (Room for the null terminator | ||
| 113 | + is included in systemdirlen) */ | ||
| 114 | + size_t filenamelen = _tcslen(filename); | ||
| 115 | + TCHAR *path = malloc(sizeof(TCHAR) * (systemdirlen + 1 + filenamelen)); | ||
| 116 | + if(path && GetSystemDirectory(path, systemdirlen)) { | ||
| 117 | + /* Calculate the full DLL path */ | ||
| 118 | + _tcscpy(path + _tcslen(path), TEXT("\\")); | ||
| 119 | + _tcscpy(path + _tcslen(path), filename); | ||
| 120 | + | ||
| 121 | + /* Load the DLL from the Windows system directory */ | ||
| 122 | + /** !checksrc! disable BANNEDFUNC 1 **/ | ||
| 123 | + hModule = pLoadLibraryEx ? | ||
| 124 | + pLoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) : | ||
| 125 | + LoadLibrary(path); | ||
| 126 | + | ||
| 127 | + } | ||
| 128 | + free(path); | ||
| 129 | + } | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + return hModule; | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + #else /* defined(_WIN32) */ | ||
| 136 | + | ||
| 137 | + /* ISO C requires a translation unit to contain at least one declaration | ||
| 138 | + [-Wempty-translation-unit] */ | ||
| 139 | + typedef int _TRANSLATION_UNIT_LOAD_LIBRARY_C_NOT_EMTPY; | ||
| 140 | + | ||
| 141 | + #endif /* defined(_WIN32) */ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,24 +2,34 @@ | |||
| 2 | 2 | * siphash.h - SipHash-2-4 in a single header file | |
| 3 | 3 | * -------------------------------------------------------------------------- | |
| 4 | 4 | * Derived by William Ahern from the reference implementation[1] published[2] | |
| 5 | - * by Jean-Philippe Aumasson and Daniel J. Berstein. Licensed in kind. | ||
| 6 | 5 | * by Jean-Philippe Aumasson and Daniel J. Berstein. | |
| 7 | - * Minimal changes by Sebastian Pipping on top, details below. | ||
| 6 | + * Minimal changes by Sebastian Pipping and Victor Stinner on top, see below. | ||
| 8 | 7 | * Licensed under the CC0 Public Domain Dedication license. | |
| 9 | 8 | * | |
| 10 | 9 | * 1. https://www.131002.net/siphash/siphash24.c | |
| 11 | 10 | * 2. https://www.131002.net/siphash/ | |
| 12 | 11 | * -------------------------------------------------------------------------- | |
| 13 | 12 | * HISTORY: | |
| 14 | 13 | * | |
| 15 | - * 2017-06-10 (Sebastian Pipping) | ||
| 14 | + * 2017-07-25 (Vadim Zeitlin) | ||
| 15 | + * - Fix use of SIPHASH_MAIN macro | ||
| 16 | + * | ||
| 17 | + * 2017-07-05 (Sebastian Pipping) | ||
| 18 | + * - Use _SIP_ULL macro to not require a C++11 compiler if compiled as C++ | ||
| 19 | + * - Add const qualifiers at two places | ||
| 20 | + * - Ensure <=80 characters line length (assuming tab width 4) | ||
| 21 | + * | ||
| 22 | + * 2017-06-23 (Victor Stinner) | ||
| 23 | + * - Address Win64 compile warnings | ||
| 24 | + * | ||
| 25 | + * 2017-06-18 (Sebastian Pipping) | ||
| 16 | 26 | * - Clarify license note in the header | |
| 17 | 27 | * - Address C89 issues: | |
| 18 | 28 | * - Stop using inline keyword (and let compiler decide) | |
| 19 | - * - Turn integer suffix ULL to UL | ||
| 20 | 29 | * - Replace _Bool by int | |
| 21 | 30 | * - Turn macro siphash24 into a function | |
| 22 | 31 | * - Address invalid conversion (void pointer) by explicit cast | |
| 32 | + * - Address lack of stdint.h for Visual Studio 2003 to 2008 | ||
| 23 | 33 | * - Always expose sip24_valid (for self-tests) | |
| 24 | 34 | * | |
| 25 | 35 | * 2012-11-04 - Born. (William Ahern) | |
@@ -76,7 +86,23 @@ | |||
| 76 | 86 | #define SIPHASH_H | |
| 77 | 87 | ||
| 78 | 88 | #include <stddef.h> /* size_t */ | |
| 79 | - #include <stdint.h> /* uint64_t uint32_t uint8_t */ | ||
| 89 | + | ||
| 90 | + #if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1600) | ||
| 91 | + /* For vs2003/7.1 up to vs2008/9.0; _MSC_VER 1600 is vs2010/10.0 */ | ||
| 92 | + typedef unsigned __int8 uint8_t; | ||
| 93 | + typedef unsigned __int32 uint32_t; | ||
| 94 | + typedef unsigned __int64 uint64_t; | ||
| 95 | + #else | ||
| 96 | + #include <stdint.h> /* uint64_t uint32_t uint8_t */ | ||
| 97 | + #endif | ||
| 98 | + | ||
| 99 | + | ||
| 100 | + /* | ||
| 101 | + * Workaround to not require a C++11 compiler for using ULL suffix | ||
| 102 | + * if this code is included and compiled as C++; related GCC warning is: | ||
| 103 | + * warning: use of C++11 long long integer constant [-Wlong-long] | ||
| 104 | + */ | ||
| 105 | + #define _SIP_ULL(high, low) (((uint64_t)high << 32) | low) | ||
| 80 | 106 | ||
| 81 | 107 | ||
| 82 | 108 | #define SIP_ROTL(x, b) (uint64_t)(((x) << (b)) | ( (x) >> (64 - (b)))) | |
@@ -158,11 +184,12 @@ static void sip_round(struct siphash *H, const int rounds) { | |||
| 158 | 184 | } /* sip_round() */ | |
| 159 | 185 | ||
| 160 | 186 | ||
| 161 | - static struct siphash *sip24_init(struct siphash *H, const struct sipkey *key) { | ||
| 162 | - H->v0 = 0x736f6d6570736575UL ^ key->k[0]; | ||
| 163 | - H->v1 = 0x646f72616e646f6dUL ^ key->k[1]; | ||
| 164 | - H->v2 = 0x6c7967656e657261UL ^ key->k[0]; | ||
| 165 | - H->v3 = 0x7465646279746573UL ^ key->k[1]; | ||
| 187 | + static struct siphash *sip24_init(struct siphash *H, | ||
| 188 | + const struct sipkey *key) { | ||
| 189 | + H->v0 = _SIP_ULL(0x736f6d65U, 0x70736575U) ^ key->k[0]; | ||
| 190 | + H->v1 = _SIP_ULL(0x646f7261U, 0x6e646f6dU) ^ key->k[1]; | ||
| 191 | + H->v2 = _SIP_ULL(0x6c796765U, 0x6e657261U) ^ key->k[0]; | ||
| 192 | + H->v3 = _SIP_ULL(0x74656462U, 0x79746573U) ^ key->k[1]; | ||
| 166 | 193 | ||
| 167 | 194 | H->p = H->buf; | |
| 168 | 195 | H->c = 0; | |
@@ -173,7 +200,8 @@ static struct siphash *sip24_init(struct siphash *H, const struct sipkey *key) { | |||
| 173 | 200 | ||
| 174 | 201 | #define sip_endof(a) (&(a)[sizeof (a) / sizeof *(a)]) | |
| 175 | 202 | ||
| 176 | - static struct siphash *sip24_update(struct siphash *H, const void *src, size_t len) { | ||
| 203 | + static struct siphash *sip24_update(struct siphash *H, const void *src, | ||
| 204 | + size_t len) { | ||
| 177 | 205 | const unsigned char *p = (const unsigned char *)src, *pe = p + len; | |
| 178 | 206 | uint64_t m; | |
| 179 | 207 | ||
@@ -198,7 +226,7 @@ static struct siphash *sip24_update(struct siphash *H, const void *src, size_t l | |||
| 198 | 226 | ||
| 199 | 227 | ||
| 200 | 228 | static uint64_t sip24_final(struct siphash *H) { | |
| 201 | - char left = H->p - H->buf; | ||
| 229 | + const char left = (char)(H->p - H->buf); | ||
| 202 | 230 | uint64_t b = (H->c + left) << 56; | |
| 203 | 231 | ||
| 204 | 232 | switch (left) { | |
@@ -222,7 +250,8 @@ static uint64_t sip24_final(struct siphash *H) { | |||
| 222 | 250 | } /* sip24_final() */ | |
| 223 | 251 | ||
| 224 | 252 | ||
| 225 | - static uint64_t siphash24(const void *src, size_t len, const struct sipkey *key) { | ||
| 253 | + static uint64_t siphash24(const void *src, size_t len, | ||
| 254 | + const struct sipkey *key) { | ||
| 226 | 255 | struct siphash state = SIPHASH_INITIALIZER; | |
| 227 | 256 | return sip24_final(sip24_update(sip24_init(&state, key), src, len)); | |
| 228 | 257 | } /* siphash24() */ | |
@@ -310,10 +339,11 @@ static int sip24_valid(void) { | |||
| 310 | 339 | struct sipkey k; | |
| 311 | 340 | size_t i; | |
| 312 | 341 | ||
| 313 | - sip_tokey(&k, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017"); | ||
| 342 | + sip_tokey(&k, "\000\001\002\003\004\005\006\007\010\011" | ||
| 343 | + "\012\013\014\015\016\017"); | ||
| 314 | 344 | ||
| 315 | 345 | for (i = 0; i < sizeof in; ++i) { | |
| 316 | - in[i] = i; | ||
| 346 | + in[i] = (unsigned char)i; | ||
| 317 | 347 | ||
| 318 | 348 | if (siphash24(in, i, &k) != SIP_U8TO64_LE(vectors[i])) | |
| 319 | 349 | return 0; | |
@@ -323,12 +353,12 @@ static int sip24_valid(void) { | |||
| 323 | 353 | } /* sip24_valid() */ | |
| 324 | 354 | ||
| 325 | 355 | ||
| 326 | - #if SIPHASH_MAIN | ||
| 356 | + #ifdef SIPHASH_MAIN | ||
| 327 | 357 | ||
| 328 | 358 | #include <stdio.h> | |
| 329 | 359 | ||
| 330 | 360 | int main(void) { | |
| 331 | - int ok = sip24_valid(); | ||
| 361 | + const int ok = sip24_valid(); | ||
| 332 | 362 | ||
| 333 | 363 | if (ok) | |
| 334 | 364 | puts("OK"); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments