{"action":"opened","issue":{"url":"https://api.github.com/repos/uutils/coreutils/issues/565","labels_url":"https://api.github.com/repos/uutils/coreutils/issues/565/labels{/name}","comments_url":"https://api.github.com/repos/uutils/coreutils/issues/565/comments","events_url":"https://api.github.com/repos/uutils/coreutils/issues/565/events","html_url":"https://github.com/uutils/coreutils/issues/565","id":72843267,"number":565,"title":"whoami Windows Uses an Oversized Buffer","user":{"login":"mattico","id":853158,"avatar_url":"https://avatars.githubusercontent.com/u/853158?v=3","gravatar_id":"","url":"https://api.github.com/users/mattico","html_url":"https://github.com/mattico","followers_url":"https://api.github.com/users/mattico/followers","following_url":"https://api.github.com/users/mattico/following{/other_user}","gists_url":"https://api.github.com/users/mattico/gists{/gist_id}","starred_url":"https://api.github.com/users/mattico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattico/subscriptions","organizations_url":"https://api.github.com/users/mattico/orgs","repos_url":"https://api.github.com/users/mattico/repos","events_url":"https://api.github.com/users/mattico/events{/privacy}","received_events_url":"https://api.github.com/users/mattico/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-03T18:16:48Z","updated_at":"2015-05-03T18:16:48Z","closed_at":null,"body":"`getusername()` in whoami uses a 2048-byte buffer to get the username from `GetUserNameA()`:\r\n```\r\n    pub unsafe fn getusername() -> String {\r\n        let mut buffer: [libc::c_char; 2048] = mem::uninitialized();   // XXX: it may be possible that this isn't long enough.  I don't know\r\n        if !GetUserNameA(buffer.as_mut_ptr(), &mut (buffer.len() as libc::uint32_t)) == 0 {\r\n            crash!(1, \"username is too long\");\r\n        }\r\n        String::from_utf8_lossy(::std::ffi::CStr::from_ptr(buffer.as_ptr()).to_bytes()).to_string()\r\n    }\r\n```\r\n\r\nWhen, in practice, usernames can only be up to 104 characters in windows (https://technet.microsoft.com/en-us/library/bb726984.aspx). It's safe to make the buffer 105 bytes."}}