{"action":"created","issue":{"url":"https://api.github.com/repos/rmyorston/busybox-w32/issues/15","labels_url":"https://api.github.com/repos/rmyorston/busybox-w32/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/rmyorston/busybox-w32/issues/15/comments","events_url":"https://api.github.com/repos/rmyorston/busybox-w32/issues/15/events","html_url":"https://github.com/rmyorston/busybox-w32/issues/15","id":20111487,"number":15,"title":"md5sum is broken due to file open mode issue","user":{"login":"iquadtree","id":5549870,"avatar_url":"https://avatars.githubusercontent.com/u/5549870?v=3","gravatar_id":"","url":"https://api.github.com/users/iquadtree","html_url":"https://github.com/iquadtree","followers_url":"https://api.github.com/users/iquadtree/followers","following_url":"https://api.github.com/users/iquadtree/following{/other_user}","gists_url":"https://api.github.com/users/iquadtree/gists{/gist_id}","starred_url":"https://api.github.com/users/iquadtree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iquadtree/subscriptions","organizations_url":"https://api.github.com/users/iquadtree/orgs","repos_url":"https://api.github.com/users/iquadtree/repos","events_url":"https://api.github.com/users/iquadtree/events{/privacy}","received_events_url":"https://api.github.com/users/iquadtree/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2013-09-26T14:05:50Z","updated_at":"2015-04-18T18:51:47Z","closed_at":"2015-04-18T11:15:57Z","body":"Reproducable with any particular binary file. Just compare the output of busybox md5sum and another MD5 hash calculator like md5sum from Cygwin. Looks like the same issue as #4.\r\n\r\nI figured out that _open() CRT call always uses text file mode (_O_TEXT) by default when opening files until it will set explicitly by the _set_fmode(). Thus ^Z (0x1A) is treated like end-of-file sequence and reading is stopped.\r\n\r\nI've tried to fix it with following patch:\r\n\r\n```diff\r\n@@ -125,10 +125,12 @@ int mingw_open (const char *filename, int oflags, ...)\r\n               va_start(args, oflags);\r\n              mode = va_arg(args, int);\r\n              va_end(args);\r\n+             oflags |= _O_BINARY; // force binary mode by default\r\n+\r\n               if (oflags & O_NONBLOCK) {\r\n                             errno = ENOSYS;\r\n                             return -1;\r\n              }\r\n              if (filename && !strcmp(filename, \"/dev/null\"))\r\n```\r\n... and it worked for me. I'm not sure about regression risks (please take a look at #4) but I suppose that line endings issue can be solved by implementing -a command-line switch for diff which seems to be ignored.\r\n"},"comment":{"url":"https://api.github.com/repos/rmyorston/busybox-w32/issues/comments/94190996","html_url":"https://github.com/rmyorston/busybox-w32/issues/15#issuecomment-94190996","issue_url":"https://api.github.com/repos/rmyorston/busybox-w32/issues/15","id":94190996,"user":{"login":"iquadtree","id":5549870,"avatar_url":"https://avatars.githubusercontent.com/u/5549870?v=3","gravatar_id":"","url":"https://api.github.com/users/iquadtree","html_url":"https://github.com/iquadtree","followers_url":"https://api.github.com/users/iquadtree/followers","following_url":"https://api.github.com/users/iquadtree/following{/other_user}","gists_url":"https://api.github.com/users/iquadtree/gists{/gist_id}","starred_url":"https://api.github.com/users/iquadtree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iquadtree/subscriptions","organizations_url":"https://api.github.com/users/iquadtree/orgs","repos_url":"https://api.github.com/users/iquadtree/repos","events_url":"https://api.github.com/users/iquadtree/events{/privacy}","received_events_url":"https://api.github.com/users/iquadtree/received_events","type":"User","site_admin":false},"created_at":"2015-04-18T18:51:47Z","updated_at":"2015-04-18T18:51:47Z","body":"Sounds good! Thank you."}}