{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/1161","labels_url":"https://api.github.com/repos/nodejs/node/issues/1161/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/1161/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/1161/events","html_url":"https://github.com/nodejs/node/issues/1161","id":62044016,"number":1161,"title":"Buffer write* silently sets 0 instead of failing for wrong values","user":{"login":"unbornchikken","id":5675531,"avatar_url":"https://avatars.githubusercontent.com/u/5675531?v=3","gravatar_id":"","url":"https://api.github.com/users/unbornchikken","html_url":"https://github.com/unbornchikken","followers_url":"https://api.github.com/users/unbornchikken/followers","following_url":"https://api.github.com/users/unbornchikken/following{/other_user}","gists_url":"https://api.github.com/users/unbornchikken/gists{/gist_id}","starred_url":"https://api.github.com/users/unbornchikken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unbornchikken/subscriptions","organizations_url":"https://api.github.com/users/unbornchikken/orgs","repos_url":"https://api.github.com/users/unbornchikken/repos","events_url":"https://api.github.com/users/unbornchikken/events{/privacy}","received_events_url":"https://api.github.com/users/unbornchikken/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nodejs/node/labels/buffer","name":"buffer","color":"f7c6c7"}],"state":"open","locked":false,"assignee":{"login":"trevnorris","id":289174,"avatar_url":"https://avatars.githubusercontent.com/u/289174?v=3","gravatar_id":"","url":"https://api.github.com/users/trevnorris","html_url":"https://github.com/trevnorris","followers_url":"https://api.github.com/users/trevnorris/followers","following_url":"https://api.github.com/users/trevnorris/following{/other_user}","gists_url":"https://api.github.com/users/trevnorris/gists{/gist_id}","starred_url":"https://api.github.com/users/trevnorris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trevnorris/subscriptions","organizations_url":"https://api.github.com/users/trevnorris/orgs","repos_url":"https://api.github.com/users/trevnorris/repos","events_url":"https://api.github.com/users/trevnorris/events{/privacy}","received_events_url":"https://api.github.com/users/trevnorris/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-03-16T10:55:12Z","updated_at":"2015-09-03T06:19:50Z","closed_at":null,"body":"Repro:\r\n\r\n```\r\n> var b = new Buffer(6);\r\nundefined\r\n> b.writeUInt32LE(10, 0);\r\n4\r\n> b.readUInt32LE(0)\r\n10\r\n> b.writeUInt32LE(\"5\", 0);\r\n4\r\n> b.readUInt32LE(0)\r\n5\r\n> b.writeUInt32LE({}, 0);\r\n4\r\n> b.readUInt32LE(0)\r\n0\r\n> b.writeUInt32LE({}, 0, false);\r\n4\r\n> b.readUInt32LE(0)\r\n0\r\n```\r\n\r\nAccording to this: https://iojs.org/api/buffer.html#buffer_buf_writeint32le_value_offset_noassert, the last three writes should be failed, because value is not a valid integer."},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/137347047","html_url":"https://github.com/nodejs/node/issues/1161#issuecomment-137347047","issue_url":"https://api.github.com/repos/nodejs/node/issues/1161","id":137347047,"user":{"login":"trevnorris","id":289174,"avatar_url":"https://avatars.githubusercontent.com/u/289174?v=3","gravatar_id":"","url":"https://api.github.com/users/trevnorris","html_url":"https://github.com/trevnorris","followers_url":"https://api.github.com/users/trevnorris/followers","following_url":"https://api.github.com/users/trevnorris/following{/other_user}","gists_url":"https://api.github.com/users/trevnorris/gists{/gist_id}","starred_url":"https://api.github.com/users/trevnorris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trevnorris/subscriptions","organizations_url":"https://api.github.com/users/trevnorris/orgs","repos_url":"https://api.github.com/users/trevnorris/repos","events_url":"https://api.github.com/users/trevnorris/events{/privacy}","received_events_url":"https://api.github.com/users/trevnorris/received_events","type":"User","site_admin":false},"created_at":"2015-09-03T06:19:50Z","updated_at":"2015-09-03T06:19:50Z","body":"Related: https://github.com/nodejs/node/issues/2668\r\n\r\nThis is because we auto coerce the value like so:\r\n```js\r\nBuffer.prototype.writeUInt32LE = function(value, offset, noAssert) {\r\n  value = +value;\r\n```\r\nI did this to improve performance, but forgot about the passing of non-numeric values. Was only considering out of range numeric values.\r\n\r\nSo current functionality doesn't match documentation. The probable best solution is to put the assert checks above the value coercion. We'll work on this in the aforementioned issue."}}