Overview
Comment: | Make +[OFSecureData isSecure] per instance
The reason for this change is that whether non-swappable memory can be It's also called -[isSwappable] now to be more precise. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
60caadeb5de31d6b2588079135062705 |
User & Date: | js on 2019-12-15 14:42:19 |
Other Links: | manifest | tags |
Context
2019-12-27
| ||
00:41 | OFSecureData: Add allowsSwappableMemory property check-in: e629dc83a9 user: js tags: trunk | |
2019-12-15
| ||
15:37 | Merge branch 'master' into 1.0 check-in: 11e303eb3b user: js tags: 1.0 | |
14:42 | Make +[OFSecureData isSecure] per instance check-in: 60caadeb5d user: js tags: trunk | |
2019-12-14
| ||
19:00 | Allow numbers for of_dns_{class,record_type}_parse check-in: 4fc1f15ab2 user: js tags: trunk | |
Changes
Modified src/OFSecureData.h from [4b4455fb4b] to [95d6612ecd].
︙ | |||
18 19 20 21 22 23 24 | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | - - + + - - + + + + + - - + + + + - - - - - - - | #import "OFData.h" OF_ASSUME_NONNULL_BEGIN /*! * @class OFSecureData OFSecureData.h ObjFW/OFSecureData.h * |
︙ |
Modified src/OFSecureData.m from [4b72bb7708] to [0b2ff22574].
︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | + - + - + - - + + - + + - + | #endif #define CHUNK_SIZE 16 struct page { struct page *next, *previous; void *map; bool swappable; unsigned char *page; }; #if defined(OF_HAVE_COMPILER_TLS) static thread_local struct page *firstPage = NULL; static thread_local struct page *lastPage = NULL; static thread_local struct page **preallocatedPages = NULL; static thread_local size_t numPreallocatedPages = 0; #elif defined(OF_HAVE_THREADS) static of_tlskey_t firstPageKey, lastPageKey; static of_tlskey_t preallocatedPagesKey, numPreallocatedPagesKey; #else static struct page *firstPage = NULL; static struct page *lastPage = NULL; static struct page **preallocatedPages = NULL; static size_t numPreallocatedPages = 0; #endif static void * |
︙ | |||
150 151 152 153 154 155 156 | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | - + | @throw [OFOutOfMemoryException exceptionWithRequestedSize: sizeof(*page)]; if ((page->map = calloc(1, mapSize)) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: mapSize]; |
︙ | |||
189 190 191 192 193 194 195 | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | - + | size_t pageSize = [OFSystemInfo pageSize]; size_t mapSize = OF_ROUND_UP_POW2(8, pageSize / CHUNK_SIZE) / 8; for (size_t i = 0; i < mapSize; i++) if (map[i] != 0) return; |
︙ | |||
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | of_explicit_memset(pointer, 0, bytes); for (size_t i = 0; i < chunks; i++) of_bitset_clear(page->map, chunkIndex + i); } @implementation OFSecureData @synthesize swappable = _swappable; #if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) + (void)initialize { if (self != [OFSecureData class]) return; if (!of_tlskey_new(&firstPageKey) || !of_tlskey_new(&lastPageKey) || !of_tlskey_new(&preallocatedPagesKey) || !of_tlskey_new(&numPreallocatedPagesKey)) @throw [OFInitializationFailedException exceptionWithClass: self]; } #endif |
︙ | |||
394 395 396 397 398 399 400 | 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | - + | size_t pageSize = [OFSystemInfo pageSize]; if (count > SIZE_MAX / itemSize) @throw [OFOutOfRangeException exception]; if (count * itemSize >= pageSize) _items = mapPages(OF_ROUND_UP_POW2(pageSize, |
︙ | |||
420 421 422 423 424 425 426 427 428 429 430 431 432 433 | 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | + + | count * itemSize); if (_items == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: count * itemSize]; } _swappable = _page->swappable; } _itemSize = itemSize; _count = count; } @catch (id e) { [self release]; @throw e; |
︙ | |||
494 495 496 497 498 499 500 | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | - + + | - (void)dealloc { size_t pageSize = [OFSystemInfo pageSize]; if (_count * _itemSize > pageSize) unmapPages(_items, |
︙ |