Title: Switch from strdup to memcpy to faithfully copy all bytes and prevent a crash in some cases. by tylerchurch · Pull Request #966 · nodegit/nodegit · GitHub
Open Graph Title: Switch from strdup to memcpy to faithfully copy all bytes and prevent a crash in some cases. by tylerchurch · Pull Request #966 · nodegit/nodegit
X Title: Switch from strdup to memcpy to faithfully copy all bytes and prevent a crash in some cases. by tylerchurch · Pull Request #966 · nodegit/nodegit
Description: This is a pull request to fix the issue I created over here: #965 To summarize over here why I'm making these changes: strdup expects a C-style null-terminated string, but sometimes we're using nodejs strings to pass in strings that contain nulls in the middle, thus failing to copy everything at best, and causing crashes from reading invalid memory locations at worst. Thus I changed to using malloc, memcpy and memset to prevent these issues. To explain my changes a little bit: I make the malloc'ed string one byte longer so I can add a terminating null character, since it looks like these templates are used in a number of different places, and for things like a repo path, where we do want things to end in a null character. I used memset instead of the more standard array-style access because most of the usages of these templates are const char *. The funky casts are because some places have void * instead of const char *, so to get the pointer arithmetic right, I had to specify the char *. C code isn't what I normally write, so let me apologize in advance if these changes aren't quite what they should be 😄 I'm happy to make any modifications necessary. The limited testing I've done seems to show that everything is working perfectly well with these changes.
Open Graph Description: This is a pull request to fix the issue I created over here: #965 To summarize over here why I'm making these changes: strdup expects a C-style null-terminated string, but sometimes we're ...
X Description: This is a pull request to fix the issue I created over here: #965 To summarize over here why I'm making these changes: strdup expects a C-style null-terminated string, but sometimes we&...
Opengraph URL: https://github.com/nodegit/nodegit/pull/966
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:08746efe-9902-6ea6-3722-3159d684535f |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BE92:18A62A:433434B:5797799:6974E1CC |
| html-safe-nonce | 4b7ddb0c1d6464e2376681a15b6180b8baad60a75162722ce7cdf304f8069235 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTkyOjE4QTYyQTo0MzM0MzRCOjU3OTc3OTk6Njk3NEUxQ0MiLCJ2aXNpdG9yX2lkIjoiNDM5MTAzODY5ODIwNDIyNTk5NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 084205c0ceb834d77f959370b1d231c84a84240e9d07d65c146314ac15a718fe |
| hovercard-subject-tag | pull_request:63982652 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/nodegit/nodegit/pull/966/files |
| twitter:image | https://avatars.githubusercontent.com/u/2380817?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/2380817?s=400&v=4 |
| og:image:alt | This is a pull request to fix the issue I created over here: #965 To summarize over here why I'm making these changes: strdup expects a C-style null-terminated string, but sometimes we're ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4a4bf5f4e28041a9d2e5c107d7d20b78b4294ba261cab243b28167c16a623a1f |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/nodegit/nodegit git https://github.com/nodegit/nodegit.git |
| octolytics-dimension-user_id | 657068 |
| octolytics-dimension-user_login | nodegit |
| octolytics-dimension-repository_id | 1383170 |
| octolytics-dimension-repository_nwo | nodegit/nodegit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1383170 |
| octolytics-dimension-repository_network_root_nwo | nodegit/nodegit |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 488b30e96dfd057fbbe44c6665ccbc030b729dde |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width