{"action":"opened","issue":{"url":"https://api.github.com/repos/google/re2/issues/10","labels_url":"https://api.github.com/repos/google/re2/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/google/re2/issues/10/comments","events_url":"https://api.github.com/repos/google/re2/issues/10/events","html_url":"https://github.com/google/re2/issues/10","id":53350881,"number":10,"title":"Include room for null character when using sprintf (Patch included)","user":{"login":"meldavis","id":9271152,"avatar_url":"https://avatars.githubusercontent.com/u/9271152?v=3","gravatar_id":"","url":"https://api.github.com/users/meldavis","html_url":"https://github.com/meldavis","followers_url":"https://api.github.com/users/meldavis/followers","following_url":"https://api.github.com/users/meldavis/following{/other_user}","gists_url":"https://api.github.com/users/meldavis/gists{/gist_id}","starred_url":"https://api.github.com/users/meldavis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meldavis/subscriptions","organizations_url":"https://api.github.com/users/meldavis/orgs","repos_url":"https://api.github.com/users/meldavis/repos","events_url":"https://api.github.com/users/meldavis/events{/privacy}","received_events_url":"https://api.github.com/users/meldavis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-04T22:20:37Z","updated_at":"2015-01-04T22:20:37Z","closed_at":null,"body":"in util/strutil.cc, buffer size for `sprintf ` must be large enough to hold the trailing null character.   Before this patch, the possible_match_test failed in MSVC at input `\"[a\\xC3\\xA1]\"`.\r\n\r\n======================================================\r\n```patch\r\n--- a/util/strutil.cc\r\n+++ b/util/strutil.cc\r\n@@ -36,9 +36,13 @@ int CEscapeString(const char* src, int src_len, char* dest,\r\n         // digit then that digit must be escaped too to prevent it being\r\n         // interpreted as part of the character code by C.\r\n         if (c < ' ' || c > '~') {\r\n-          if (dest_len - used < 4) // need space for 4 letter escape\r\n+          if (dest_len - used < 5) // need space for 4 letter escape and null\r\n             return -1;\r\n+#ifndef _WIN32\r\n           sprintf(dest + used, \"\\\\%03o\", c);\r\n+#else\r\n+          sprintf_s(dest + used, 5, \"\\\\%03o\", c);\r\n+#endif\r\n           used += 4;\r\n         } else {\r\n           dest[used++] = c; break;\r\n```\r\n\r\n\r\n\r\n"}}