{"action":"created","issue":{"url":"https://api.github.com/repos/bitcoin/bitcoin/issues/13391","repository_url":"https://api.github.com/repos/bitcoin/bitcoin","labels_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/13391/labels{/name}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/13391/comments","events_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/13391/events","html_url":"https://github.com/bitcoin/bitcoin/pull/13391","id":329061569,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyNDEyNjk4","number":13391,"title":"Make tinyformat noexcept: Use default error handling (assert(0 && reason)) on incorrect format strings","user":{"login":"practicalswift","id":7826565,"node_id":"MDQ6VXNlcjc4MjY1NjU=","avatar_url":"https://avatars3.githubusercontent.com/u/7826565?v=4","gravatar_id":"","url":"https://api.github.com/users/practicalswift","html_url":"https://github.com/practicalswift","followers_url":"https://api.github.com/users/practicalswift/followers","following_url":"https://api.github.com/users/practicalswift/following{/other_user}","gists_url":"https://api.github.com/users/practicalswift/gists{/gist_id}","starred_url":"https://api.github.com/users/practicalswift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/practicalswift/subscriptions","organizations_url":"https://api.github.com/users/practicalswift/orgs","repos_url":"https://api.github.com/users/practicalswift/repos","events_url":"https://api.github.com/users/practicalswift/events{/privacy}","received_events_url":"https://api.github.com/users/practicalswift/received_events","type":"User","site_admin":false},"labels":[{"id":241832923,"node_id":"MDU6TGFiZWwyNDE4MzI5MjM=","url":"https://api.github.com/repos/bitcoin/bitcoin/labels/Utils/log/libs","name":"Utils/log/libs","color":"5319e7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-06-04T13:43:28Z","updated_at":"2018-06-04T14:18:38Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/13391","html_url":"https://github.com/bitcoin/bitcoin/pull/13391","diff_url":"https://github.com/bitcoin/bitcoin/pull/13391.diff","patch_url":"https://github.com/bitcoin/bitcoin/pull/13391.patch"},"body":"Make tinyformat `noexcept`: Use tinyformat's default error handling (`assert(0 && reason);`) instead of throwing `tinyformat::format_error` on incorrect format strings.\r\n\r\nThe only place where `tinyformat::format_error` was handled was in `LogPrintf(...)` where it was handled to generate output which is equivalent to what `assert(0 && reason);` provides.\r\n\r\nIncorrect format strings are best handled explicitly locally in a \"fail fast\" manner. No need for propagation.\r\n\r\nSince tinyformat is used extensively via `strprintf(…)` large parts of the code base are switched from an implicit \"might throw `tinyformat::format_error`\" to \"will not throw\" from a compiler/static analyzer perspective with this change.\r\n\r\nReducing the number of unnecessary exceptions thrown increases the signal-to-noise for humans when analyzing potential issues introduced by uncaught exceptions.\r\n\r\nThese were the conditions that threw `tinyformat::format_error` prior to this commit:\r\n\r\n```\r\n$ git grep TINYFORMAT_ERROR\r\nsrc/tinyformat.h:// Error handling: Define TINYFORMAT_ERROR to customize the error handling for\r\nsrc/tinyformat.h:#define TINYFORMAT_ERROR(reasonString) throw tinyformat::format_error(reasonString)\r\nsrc/tinyformat.h:#ifndef TINYFORMAT_ERROR\r\nsrc/tinyformat.h:#   define TINYFORMAT_ERROR(reason) assert(0 && reason)\r\nsrc/tinyformat.h:        TINYFORMAT_ERROR(\"tinyformat: Cannot convert from argument type to \"\r\nsrc/tinyformat.h:        TINYFORMAT_ERROR(\"tinyformat: Not enough conversion specifiers in format string\");\r\nsrc/tinyformat.h:            TINYFORMAT_ERROR(\"tinyformat: Not enough arguments to read variable width\");\r\nsrc/tinyformat.h:                TINYFORMAT_ERROR(\"tinyformat: Not enough arguments to read variable precision\");\r\nsrc/tinyformat.h:            TINYFORMAT_ERROR(\"tinyformat: the %a and %A conversion specs \"\r\nsrc/tinyformat.h:            TINYFORMAT_ERROR(\"tinyformat: %n conversion spec not supported\");\r\nsrc/tinyformat.h:            TINYFORMAT_ERROR(\"tinyformat: Conversion spec incorrectly \"\r\nsrc/tinyformat.h:            TINYFORMAT_ERROR(\"tinyformat: Not enough format arguments\");\r\nsrc/tinyformat.h:        TINYFORMAT_ERROR(\"tinyformat: Too many conversion specifiers in format string\");\r\n```"},"comment":{"url":"https://api.github.com/repos/bitcoin/bitcoin/issues/comments/394371112","html_url":"https://github.com/bitcoin/bitcoin/pull/13391#issuecomment-394371112","issue_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/13391","id":394371112,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDM3MTExMg==","user":{"login":"laanwj","id":126646,"node_id":"MDQ6VXNlcjEyNjY0Ng==","avatar_url":"https://avatars0.githubusercontent.com/u/126646?v=4","gravatar_id":"","url":"https://api.github.com/users/laanwj","html_url":"https://github.com/laanwj","followers_url":"https://api.github.com/users/laanwj/followers","following_url":"https://api.github.com/users/laanwj/following{/other_user}","gists_url":"https://api.github.com/users/laanwj/gists{/gist_id}","starred_url":"https://api.github.com/users/laanwj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laanwj/subscriptions","organizations_url":"https://api.github.com/users/laanwj/orgs","repos_url":"https://api.github.com/users/laanwj/repos","events_url":"https://api.github.com/users/laanwj/events{/privacy}","received_events_url":"https://api.github.com/users/laanwj/received_events","type":"User","site_admin":false},"created_at":"2018-06-04T14:18:38Z","updated_at":"2018-06-04T14:18:38Z","author_association":"MEMBER","body":"> Could you describe the issue that resulted in a near DoS vulnerability? As I read it #9963 was more about developer ergonomics? :-)\r\n\r\nI think we intentionally didn't mention the issue there.\r\nIt's very simply: have an under-tested error path in the network code with an invalid LogPrintf() spec. Anything that triggers this will crash the process. A little loggable offense turns into a full DoS vector.\r\n\r\n> Could a middle ground be to make strprintf(…) noexcept and keep LogPrintf(...) as is?\r\n\r\nI think that would be a better idea. If the output isn't just used for logging, it's a more serious error in any case."}}
{"actor":{"display_login":"laanwj"}}