{"action":"created","issue":{"url":"https://api.github.com/repos/pilight/pilight/issues/232","labels_url":"https://api.github.com/repos/pilight/pilight/issues/232/labels{/name}","comments_url":"https://api.github.com/repos/pilight/pilight/issues/232/comments","events_url":"https://api.github.com/repos/pilight/pilight/issues/232/events","html_url":"https://github.com/pilight/pilight/pull/232","id":130101720,"number":232,"title":"Fix buffer overflow in setenv() and unsetenv() functions.","user":{"login":"yablacky","id":16855814,"avatar_url":"https://avatars.githubusercontent.com/u/16855814?v=3","gravatar_id":"","url":"https://api.github.com/users/yablacky","html_url":"https://github.com/yablacky","followers_url":"https://api.github.com/users/yablacky/followers","following_url":"https://api.github.com/users/yablacky/following{/other_user}","gists_url":"https://api.github.com/users/yablacky/gists{/gist_id}","starred_url":"https://api.github.com/users/yablacky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yablacky/subscriptions","organizations_url":"https://api.github.com/users/yablacky/orgs","repos_url":"https://api.github.com/users/yablacky/repos","events_url":"https://api.github.com/users/yablacky/events{/privacy}","received_events_url":"https://api.github.com/users/yablacky/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-01-31T08:40:07Z","updated_at":"2016-01-31T11:02:34Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pilight/pilight/pulls/232","html_url":"https://github.com/pilight/pilight/pull/232","diff_url":"https://github.com/pilight/pilight/pull/232.diff","patch_url":"https://github.com/pilight/pilight/pull/232.patch"},"body":"A buffer allocated by setenv() and unsetenv() was one byte too short.\r\nIf setenv() was called with option to not overwrite an existing variable\r\nand that variable does not exist, then a NULL pointer was used and a\r\nsegfault happens (if the variable exists, it was unnecessary set again\r\nto its current value). All this has been fixed.\r\n\r\nFurther the parameters passed to setenv() and unsetenv() are now checked\r\nagainst NULL pointers and the functions do the best they can do without\r\ncrashing (return with failure indicator and errno set). This introduced\r\na feature for setenv() that, if called with a variable name but a value\r\nof NULL, it does an unsetenv()."},"comment":{"url":"https://api.github.com/repos/pilight/pilight/issues/comments/177467294","html_url":"https://github.com/pilight/pilight/pull/232#issuecomment-177467294","issue_url":"https://api.github.com/repos/pilight/pilight/issues/232","id":177467294,"user":{"login":"CurlyMoo","id":2429105,"avatar_url":"https://avatars.githubusercontent.com/u/2429105?v=3","gravatar_id":"","url":"https://api.github.com/users/CurlyMoo","html_url":"https://github.com/CurlyMoo","followers_url":"https://api.github.com/users/CurlyMoo/followers","following_url":"https://api.github.com/users/CurlyMoo/following{/other_user}","gists_url":"https://api.github.com/users/CurlyMoo/gists{/gist_id}","starred_url":"https://api.github.com/users/CurlyMoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CurlyMoo/subscriptions","organizations_url":"https://api.github.com/users/CurlyMoo/orgs","repos_url":"https://api.github.com/users/CurlyMoo/repos","events_url":"https://api.github.com/users/CurlyMoo/events{/privacy}","received_events_url":"https://api.github.com/users/CurlyMoo/received_events","type":"User","site_admin":false},"created_at":"2016-01-31T11:02:34Z","updated_at":"2016-01-31T11:02:34Z","body":"That's also the reason why i keep my code as verbose as possible. I try to avoid the\r\n```\r\nif(something(...)) {\r\n   ...\r\n} else {\r\n   ...\r\n}\r\n```\r\nbecause it doesn't tell me anything about the variable types that the function returns.\r\n`if(name == NULL)` and `if(name == 0)` are 99% the same thing, however, the `NULL` tells me we are comparing a pointer, and the `0` tells me we are comparing a numeric value.\r\n"}}