{"action":"created","issue":{"url":"https://api.github.com/repos/openssl/openssl/issues/6569","repository_url":"https://api.github.com/repos/openssl/openssl","labels_url":"https://api.github.com/repos/openssl/openssl/issues/6569/labels{/name}","comments_url":"https://api.github.com/repos/openssl/openssl/issues/6569/comments","events_url":"https://api.github.com/repos/openssl/openssl/issues/6569/events","html_url":"https://github.com/openssl/openssl/issues/6569","id":335062283,"node_id":"MDU6SXNzdWUzMzUwNjIyODM=","number":6569,"title":"Shall we check the return value of ASN1_INTEGER_set() call in crypto/pkcs12/p12_init.c?","user":{"login":"tomgu1991","id":8084978,"node_id":"MDQ6VXNlcjgwODQ5Nzg=","avatar_url":"https://avatars2.githubusercontent.com/u/8084978?v=4","gravatar_id":"","url":"https://api.github.com/users/tomgu1991","html_url":"https://github.com/tomgu1991","followers_url":"https://api.github.com/users/tomgu1991/followers","following_url":"https://api.github.com/users/tomgu1991/following{/other_user}","gists_url":"https://api.github.com/users/tomgu1991/gists{/gist_id}","starred_url":"https://api.github.com/users/tomgu1991/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomgu1991/subscriptions","organizations_url":"https://api.github.com/users/tomgu1991/orgs","repos_url":"https://api.github.com/users/tomgu1991/repos","events_url":"https://api.github.com/users/tomgu1991/events{/privacy}","received_events_url":"https://api.github.com/users/tomgu1991/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-23T03:05:18Z","updated_at":"2018-07-02T16:43:27Z","closed_at":"2018-07-02T16:43:27Z","author_association":"NONE","body":" [ASN1_INTEGER_set()](https://www.openssl.org/docs/manmaster/man3/ASN1_INTEGER_set.html) sets the value of **ASN1_INTEGER** **a** to the **long** value **v**. The return value 0 is for failure. \r\n\r\nWell, the API reference manual contains a bug\r\n```\r\nlong ASN1_INTEGER_set(const ASN1_INTEGER *a);\r\n\r\nShall it be\r\nlong ASN1_INTEGER_set(const ASN1_INTEGER *a, long v);\r\n\r\n```\r\n\r\n\r\nIn method PKCS12_init() of crypto/pkcs12/p12_init.c, the error check of return value is missed, which may impact the result of PKCS12_init.\r\n\r\nBecides, we find the return value of this call been checked in other files in pkcs12 folder.\r\n\r\nSuch as,\r\n```c\r\npkcs12/p12_mutl.c,PKCS12_setup_mac:213-220\r\n        if ((p12->mac->iter = ASN1_INTEGER_new()) == NULL) {\r\n            PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE);\r\n            return 0;\r\n        }\r\n        if (!ASN1_INTEGER_set(p12->mac->iter, iter)) {\r\n            PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE);\r\n            return 0;\r\n        }\r\n```\r\n\r\n\r\nThis problem exists in many versions:\r\nOpenSSL_1_1_0-stable/crypto/pkcs12/p12_init.c,\r\nOpenSSL_1_1_1-pre8/crypto/pkcs12/p12_init.c,\r\nOpenSSL_1_1_1-pre4/crypto/pkcs12/p12_init.c, et al.\r\n\r\nZuxing Gu, Jiecheng Wu\r\n"},"comment":{"url":"https://api.github.com/repos/openssl/openssl/issues/comments/401864848","html_url":"https://github.com/openssl/openssl/issues/6569#issuecomment-401864848","issue_url":"https://api.github.com/repos/openssl/openssl/issues/6569","id":401864848,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTg2NDg0OA==","user":{"login":"mattcaswell","id":7422273,"node_id":"MDQ6VXNlcjc0MjIyNzM=","avatar_url":"https://avatars0.githubusercontent.com/u/7422273?v=4","gravatar_id":"","url":"https://api.github.com/users/mattcaswell","html_url":"https://github.com/mattcaswell","followers_url":"https://api.github.com/users/mattcaswell/followers","following_url":"https://api.github.com/users/mattcaswell/following{/other_user}","gists_url":"https://api.github.com/users/mattcaswell/gists{/gist_id}","starred_url":"https://api.github.com/users/mattcaswell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattcaswell/subscriptions","organizations_url":"https://api.github.com/users/mattcaswell/orgs","repos_url":"https://api.github.com/users/mattcaswell/repos","events_url":"https://api.github.com/users/mattcaswell/events{/privacy}","received_events_url":"https://api.github.com/users/mattcaswell/received_events","type":"User","site_admin":false},"created_at":"2018-07-02T16:43:27Z","updated_at":"2018-07-02T16:43:27Z","author_association":"MEMBER","body":"#6578 got merged so closing this."}}
{"actor":{"display_login":"mattcaswell"}}