{"action":"created","issue":{"url":"https://api.github.com/repos/kgabis/parson/issues/24","labels_url":"https://api.github.com/repos/kgabis/parson/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/kgabis/parson/issues/24/comments","events_url":"https://api.github.com/repos/kgabis/parson/issues/24/events","html_url":"https://github.com/kgabis/parson/issues/24","id":65687090,"number":24,"title":"Buffer overrun","user":{"login":"stuertz","id":4446612,"avatar_url":"https://avatars.githubusercontent.com/u/4446612?v=3","gravatar_id":"","url":"https://api.github.com/users/stuertz","html_url":"https://github.com/stuertz","followers_url":"https://api.github.com/users/stuertz/followers","following_url":"https://api.github.com/users/stuertz/following{/other_user}","gists_url":"https://api.github.com/users/stuertz/gists{/gist_id}","starred_url":"https://api.github.com/users/stuertz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stuertz/subscriptions","organizations_url":"https://api.github.com/users/stuertz/orgs","repos_url":"https://api.github.com/users/stuertz/repos","events_url":"https://api.github.com/users/stuertz/events{/privacy}","received_events_url":"https://api.github.com/users/stuertz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-04-01T13:42:18Z","updated_at":"2015-04-02T06:30:02Z","closed_at":null,"body":"Hi, i tried using your lib to generate logs, which works fine for simple cases. I'm currently using VS2008 and will also use gcc.\r\n\r\nBut as soon as I add a longer message containing backslashes I do get a crash calling json_serialize_to_string():\r\n\r\n    const char* msg = \"Environment: \\npid=13232\\nhostname=con-js\\nALLUSERSPROFILE=C:\\ProgramData\\nAPPDATA=C:\\Users\\js\\AppData\\Roaming\";\r\n    JSON_Value *root_value = json_value_init_object();\r\n    JSON_Object *root_object = json_value_get_object(root_value);\r\n    char *serialized_string = NULL;\r\n    json_object_set_string(root_object, \"message\", msg);\r\n    serialized_string = json_serialize_to_string(root_value);\r\n    json_free_serialized_string(serialized_string);\r\n    json_value_free(root_value);\r\n\r\nIt looks like json_serialize_string writes over the bounds of buf, which causes to stop.\r\n\r\nThe call stack:\r\n\r\n    msvcr90.dll!_crt_debugger_hook(int _Reserved=12770140)  Zeile 65\tC\r\n    msvcr90.dll!_invalid_parameter(const wchar_t * pszExpression=0x00000000, const wchar_t * pszFunction=0x00000000, const wchar_t * pszFile=0x00000000, unsigned int nLine=0, unsigned int pReserved=0)  Zeile 112 + 0x7 Bytes\tC++\r\n    msvcr90.dll!sprintf(char * string=0x00000000, const char * format=0x040baff0, ...)  Zeile 105 + 0x1c Bytes\tC\r\n    _cdbwrapc.pyd!json_serialize_to_buffer_r(const json_value_t * value=0x0490c068, char * buf=0x00000000)  Zeile 698 + 0xf Bytes\tC\r\n    _cdbwrapc.pyd!json_serialize_to_buffer(const json_value_t * value=0x0490c068, char * buf=0x0496a380, unsigned int buf_size_in_bytes=97)  Zeile 1075 + 0xd Bytes\tC\r\n    _cdbwrapc.pyd!json_serialize_to_string(const json_value_t * value=0x0490c068)  Zeile 1107 + 0x11 Bytes\tC\r\n\r\nAm I guessing right, or did you watch similar behaviour before?"},"comment":{"url":"https://api.github.com/repos/kgabis/parson/issues/comments/88764020","html_url":"https://github.com/kgabis/parson/issues/24#issuecomment-88764020","issue_url":"https://api.github.com/repos/kgabis/parson/issues/24","id":88764020,"user":{"login":"NialG","id":1234600,"avatar_url":"https://avatars.githubusercontent.com/u/1234600?v=3","gravatar_id":"","url":"https://api.github.com/users/NialG","html_url":"https://github.com/NialG","followers_url":"https://api.github.com/users/NialG/followers","following_url":"https://api.github.com/users/NialG/following{/other_user}","gists_url":"https://api.github.com/users/NialG/gists{/gist_id}","starred_url":"https://api.github.com/users/NialG/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NialG/subscriptions","organizations_url":"https://api.github.com/users/NialG/orgs","repos_url":"https://api.github.com/users/NialG/repos","events_url":"https://api.github.com/users/NialG/events{/privacy}","received_events_url":"https://api.github.com/users/NialG/received_events","type":"User","site_admin":false},"created_at":"2015-04-02T06:30:02Z","updated_at":"2015-04-02T06:30:02Z","body":"Here's some simple code that'll reproduce the issue:\r\n\r\n`JSON_Value *root_value = json_value_init_object();\r\nJSON_Object *root_object = json_value_get_object(root_value);\r\n\r\nchar *serialized_string = NULL;\r\njson_object_set_string(root_object, \"name\", \"John \\\\Smith\");\r\nserialized_string = json_serialize_to_string(root_value);\r\njson_free_serialized_string(serialized_string);\r\njson_value_free(root_value);`"}}