Title: Fix memory safety issues in KeyCodeConverter by PekingSpades · Pull Request #2 · fe9lix/CodingKeys · GitHub
Open Graph Title: Fix memory safety issues in KeyCodeConverter by PekingSpades · Pull Request #2 · fe9lix/CodingKeys
X Title: Fix memory safety issues in KeyCodeConverter by PekingSpades · Pull Request #2 · fe9lix/CodingKeys
Description: Summary Fix memory safety issues in KeyCodeConverter.m: Add NULL checks for CFStringCreateWithCharacters return value Add NULL checks for TISCopyCurrentKeyboardInputSource and TISGetInputSourceProperty return values to prevent crashes Fix pointer size mismatch in CFDictionaryGetValueIfPresent call that could cause stack corruption on 64-bit systems Problem The keyCodeForChar function has a critical bug: it passes a pointer to CGKeyCode (which is uint16_t, 2 bytes) to CFDictionaryGetValueIfPresent, but this function writes a pointer-sized value (8 bytes on 64-bit systems). This causes stack overflow and corrupts adjacent memory. Additionally, several CoreFoundation functions that can return NULL were not checked before use, which could lead to crashes. Changes keyCodeForChar function: Added NULL check for charStr after CFStringCreateWithCharacters Changed from (const void **)&code to using a proper pointer-sized variable codeValue, then safely casting to CGKeyCode createStringForKey function: Added NULL check for TISCopyCurrentKeyboardInputSource return value Added NULL check for TISGetInputSourceProperty return value with proper cleanup of currentKeyboard References Apple CF/CFDictionary.h - Documents that CFDictionaryGetValueIfPresent value parameter receives "the pointer-sized value" Apple Developer Forums - TISGetInputSourceProperty - Discusses NULL return cases for TIS functions Apple Developer Documentation - Investigating memory access crashes
Open Graph Description: Summary Fix memory safety issues in KeyCodeConverter.m: Add NULL checks for CFStringCreateWithCharacters return value Add NULL checks for TISCopyCurrentKeyboardInputSource and TISGetInputSourcePro...
X Description: Summary Fix memory safety issues in KeyCodeConverter.m: Add NULL checks for CFStringCreateWithCharacters return value Add NULL checks for TISCopyCurrentKeyboardInputSource and TISGetInputSourcePro...
Opengraph URL: https://github.com/fe9lix/CodingKeys/pull/2
X: @github
Domain: patch-diff.githubusercontent.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:c72b9de9-5e18-1038-20d1-f1db452343ba |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | AB7E:3ECB07:2A09B0:3B0FB3:698DF662 |
| html-safe-nonce | 2273ca63d890da73218aaf3c131f7e79627ce046724e29d3388dc2823fe7da03 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQjdFOjNFQ0IwNzoyQTA5QjA6M0IwRkIzOjY5OERGNjYyIiwidmlzaXRvcl9pZCI6IjQ1Mjg4NTk1MzQ0MDAwMjYyMTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5379bb26efd50c72aeaa0df864ad2d9892230365a10303eeaf818d68e124462e |
| hovercard-subject-tag | pull_request:3138966338 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/fe9lix/CodingKeys/pull/2/checks |
| twitter:image | https://avatars.githubusercontent.com/u/180665176?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/180665176?s=400&v=4 |
| og:image:alt | Summary Fix memory safety issues in KeyCodeConverter.m: Add NULL checks for CFStringCreateWithCharacters return value Add NULL checks for TISCopyCurrentKeyboardInputSource and TISGetInputSourcePro... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ae22ef6ad27c5aeb770c5acd314c5724055bb23a663877aafdaaa50ed317ba34 |
| turbo-cache-control | no-preview |
| go-import | github.com/fe9lix/CodingKeys git https://github.com/fe9lix/CodingKeys.git |
| octolytics-dimension-user_id | 213498 |
| octolytics-dimension-user_login | fe9lix |
| octolytics-dimension-repository_id | 14282422 |
| octolytics-dimension-repository_nwo | fe9lix/CodingKeys |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14282422 |
| octolytics-dimension-repository_network_root_nwo | fe9lix/CodingKeys |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e545f5becd5b3ce9b429b68c3f994ad93c680ddb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width