{"action":"created","issue":{"url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1157","labels_url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1157/labels{/name}","comments_url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1157/comments","events_url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1157/events","html_url":"https://github.com/magnumripper/JohnTheRipper/issues/1157","id":64503112,"number":1157,"title":"--input-encoding problem","user":{"login":"loverszhaokai","id":2187242,"avatar_url":"https://avatars.githubusercontent.com/u/2187242?v=3","gravatar_id":"","url":"https://api.github.com/users/loverszhaokai","html_url":"https://github.com/loverszhaokai","followers_url":"https://api.github.com/users/loverszhaokai/followers","following_url":"https://api.github.com/users/loverszhaokai/following{/other_user}","gists_url":"https://api.github.com/users/loverszhaokai/gists{/gist_id}","starred_url":"https://api.github.com/users/loverszhaokai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loverszhaokai/subscriptions","organizations_url":"https://api.github.com/users/loverszhaokai/orgs","repos_url":"https://api.github.com/users/loverszhaokai/repos","events_url":"https://api.github.com/users/loverszhaokai/events{/privacy}","received_events_url":"https://api.github.com/users/loverszhaokai/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/magnumripper/JohnTheRipper/labels/bug","name":"bug","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-26T11:27:50Z","updated_at":"2015-03-26T12:47:30Z","closed_at":null,"body":"# 1. Compare the two cases\r\n\r\nBoth Case 1 and Case 2 are invalid.\r\n\r\n## 1.1 Case 1\r\n$ ./john  7z_fmt --input-encoding=11\r\n\r\n**Invalid encoding**. Supported encodings:\r\nASCII, UTF-8, ISO-8859-1 (or latin1), ISO-8859-2, ISO-8859-7, ISO-8859-15, KOI8-R,\r\nCP437, CP720, CP737, CP850, CP852, CP858, CP866, CP868,\r\nCP1250, CP1251, CP1252, CP1253, CP1254, CP1255, CP1256\r\n\r\n## 1.2 Case 2\r\n$ ./john 7z_fmt --input-encoding=11111111111111111111111111111111111\r\n\r\nLoaded 1 password hash (7z, 7-Zip [SHA256 AES 32/64])\r\nWill run 8 OpenMP threads\r\nNote: This format may emit false positives, so it will keep trying even after\r\nfinding a possible candidate.\r\nPress 'q' or Ctrl-C to abort, almost any other key for status\r\npassword         (?)\r\n\r\n# 2. Debug\r\n\r\nI think john should **report error message** and **exit** in Case 2.\r\n\r\n## 2.1 unicode::cp_name2id()\r\n\r\nLocation:  unicode.c    int  cp_name2id(char *encoding)\r\n\r\n```C\r\n int cp_name2id(char *encoding)\r\n {\r\n         char enc[16] = \"\";\r\n         char *d = enc;\r\n \r\n         if (!encoding || strlen(encoding) > sizeof(enc))\r\n                return CP_UNDEF;\r\n         ...\r\n\r\n         if (!strcmp(enc, \"raw\") || !strcmp(enc, \"ascii\"))\r\n               return ASCII;\r\n         else\r\n\r\n         fprintf(stderr, \"Invalid encoding. Supported encodings:\\n\");\r\n         listEncodings(stderr);\r\n         exit(EXIT_FAILURE);\r\n}\r\n```\r\n\r\n16 == sizeof(enc), so the cp_name2id() will return **CP_UNDEF** for **long encoding** in Case 2. \r\nWhy not print error message?\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/comments/86498487","html_url":"https://github.com/magnumripper/JohnTheRipper/issues/1157#issuecomment-86498487","issue_url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1157","id":86498487,"user":{"login":"loverszhaokai","id":2187242,"avatar_url":"https://avatars.githubusercontent.com/u/2187242?v=3","gravatar_id":"","url":"https://api.github.com/users/loverszhaokai","html_url":"https://github.com/loverszhaokai","followers_url":"https://api.github.com/users/loverszhaokai/followers","following_url":"https://api.github.com/users/loverszhaokai/following{/other_user}","gists_url":"https://api.github.com/users/loverszhaokai/gists{/gist_id}","starred_url":"https://api.github.com/users/loverszhaokai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loverszhaokai/subscriptions","organizations_url":"https://api.github.com/users/loverszhaokai/orgs","repos_url":"https://api.github.com/users/loverszhaokai/repos","events_url":"https://api.github.com/users/loverszhaokai/events{/privacy}","received_events_url":"https://api.github.com/users/loverszhaokai/received_events","type":"User","site_admin":false},"created_at":"2015-03-26T12:47:30Z","updated_at":"2015-03-26T12:47:30Z","body":"@magnumripper  OK, I will fix this bug and test again. Thanks."}}