{"action":"created","issue":{"url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1108","labels_url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1108/labels{/name}","comments_url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1108/comments","events_url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1108/events","html_url":"https://github.com/magnumripper/JohnTheRipper/issues/1108","id":62016428,"number":1108,"title":"Format valid problem by strtok()","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":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2015-03-16T09:04:11Z","updated_at":"2015-03-16T22:44:55Z","closed_at":null,"body":"Some of the formats valid by strtok(), such as [src/agilekeychain_fmt_plug.c](https://github.com/magnumripper/JohnTheRipper/blob/bleeding-jumbo/src/agilekeychain_fmt_plug.c)\r\n\r\n```c\r\nstatic int valid(char *ciphertext, struct fmt_main *self)\r\n{\r\n\tchar *ctcopy, *keeptr;\r\n\tint ctlen;\r\n\tint saltlen;\r\n\tchar *p;\r\n\r\n\tif (strncmp(ciphertext,  \"$agilekeychain$\", 15) != 0)\r\n\t\treturn 0;\r\n\tctcopy = strdup(ciphertext);\r\n\tkeeptr = ctcopy;\r\n\tctcopy += 15;\r\n\tif ((p = strtok(ctcopy, \"*\")) == NULL)\t/* nkeys */\r\n\t\tgoto err;\r\n\tif(atoi(p) > 2)\r\n\t\tgoto err;\r\n\tif ((p = strtok(NULL, \"*\")) == NULL)\t/* iterations */\r\n\t\tgoto err;\r\n    ...\r\n}\r\n```\r\n\r\nHere is a valid format:\r\n\r\n```c\r\n\"$agilekeychain$2*1000*8*7146eaa1cca395e5*1040*here omit 2080 characters*1000*8*c05f3bc3e7f3cad7*1040*here omit 2080 characters\"\r\n```\r\n\r\nHere is another **valid** format: \r\n(This case can pass the valid(), but I think it's **not valid**, for there are too many '*')\r\n\r\n```c\r\n\"$agilekeychain$2*************************1000*8*7146eaa1cca395e5*1040*here omit 2080 characters*1000*8*c05f3bc3e7f3cad7*1040*here omit 2080 characters\"\r\n```\r\n\r\nThe problem is caused by strtok(), some formats use it in valid(). **Does it matter**?"},"comment":{"url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/comments/81971796","html_url":"https://github.com/magnumripper/JohnTheRipper/issues/1108#issuecomment-81971796","issue_url":"https://api.github.com/repos/magnumripper/JohnTheRipper/issues/1108","id":81971796,"user":{"login":"jfoug","id":1270024,"avatar_url":"https://avatars.githubusercontent.com/u/1270024?v=3","gravatar_id":"","url":"https://api.github.com/users/jfoug","html_url":"https://github.com/jfoug","followers_url":"https://api.github.com/users/jfoug/followers","following_url":"https://api.github.com/users/jfoug/following{/other_user}","gists_url":"https://api.github.com/users/jfoug/gists{/gist_id}","starred_url":"https://api.github.com/users/jfoug/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfoug/subscriptions","organizations_url":"https://api.github.com/users/jfoug/orgs","repos_url":"https://api.github.com/users/jfoug/repos","events_url":"https://api.github.com/users/jfoug/events{/privacy}","received_events_url":"https://api.github.com/users/jfoug/received_events","type":"User","site_admin":false},"created_at":"2015-03-16T22:44:55Z","updated_at":"2015-03-16T22:44:55Z","body":"> you refer to would just have +6 instead of +5\r\n\r\nI did exactly that. Only a handful.  I really hate to suck up the leading delims.  I see that as a side affect of the poor design of merging the delims (same for trailing).    I have left my code as it is, and it will give you a token (possibly empty) for EVERY delim in the string.\r\n\r\nI have checked in all files that 'required' to be changed. I have not checked in misc.[ch] which actually have the strtokm() function in it (yet)."}}