#27764 closed defect (fixed)

crypto_rsa.c: CID 1439488: Resource leaks

Reported by: asn Owned by:
Priority: Medium Milestone: Tor: 0.3.5.x-final
Component: Core Tor/Tor Version:
Severity: Normal Keywords: tor-crypto coverity
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


Coverity report from 18th Sept:

/src/lib/crypt_ops/crypto_rsa.c: 558 in crypto_pk_read_private_key_from_filename()
552     {
553       struct stat st;
554       char *buf = read_file_to_str(keyfile, 0, &st);
555       if (!buf)
556         return -1;
557       if (st.st_size > MAX_PRIVKEY_FILE_LEN)
>>>     CID 1439488:  Resource leaks  (RESOURCE_LEAK)
>>>     Variable "buf" going out of scope leaks the storage it points to.
558         return -1;
560       int rv = crypto_pk_read_private_key_from_string(env, buf,
561                                                       (ssize_t)st.st_size);
562       memwipe(buf, 0, (size_t)st.st_size);
563       tor_free(buf);

Child Tickets

Change History (3)

comment:1 Changed 11 months ago by asn

Fix is as simple as doing tor_free(buf) before the return -1.

comment:2 Changed 11 months ago by asn

Status: newneeds_review

Fix in branch bug27764.

comment:3 Changed 11 months ago by nickm

Resolution: fixed
Status: needs_reviewclosed

merged and added a changes file!

Note: See TracTickets for help on using tickets.