[asterisk-bugs] [JIRA] (ASTERISK-20858) app_minivm fails to clean up mkstemp files

Rusty Newton (JIRA) noreply at issues.asterisk.org
Fri Jan 4 13:03:45 CST 2013


     [ https://issues.asterisk.org/jira/browse/ASTERISK-20858?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rusty Newton updated ASTERISK-20858:
------------------------------------

    Status: Open  (was: Triage)
    
> app_minivm fails to clean up mkstemp files
> ------------------------------------------
>
>                 Key: ASTERISK-20858
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-20858
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Applications/app_minivm
>            Reporter: Walter Doekes
>            Severity: Minor
>
> Matt recently touched this code and removed a comment about leaking fd's and files.
> {noformat}
>                 tmpfd = mkstemp(newtmp);
>                 if (tmpfd < 0) {
>                         ast_log(LOG_WARNING, "Failed to create temporary file for volgain: %d\n", errno);
>                         ast_free(str1);
>                         ast_free(str2);
>                         return -1;
>                 }
>                 snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, filename, format, newtmp, format);
>                 ast_safe_system(tmpcmd);
> {noformat}
> The fd leaks may be gone, but this looks like:
> (a) file leaks
> (b) misuse of mkstemp by appending format to the filename
> First we have mkstemp create an actual file "/tmp/ABCDEF" and then we write to "/tmp/ABCDEF.wav". No one cares about the original "/tmp/ABCDEF" on disk, and by writing to "/tmp/ABCDEF.wav" you're ignoring most of the functionality of mkstemp -- being secure and not overwriting existing files.
> Lastly, no one ever clears up fname (finalfilename.format), resulting in a second file leak.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the asterisk-bugs mailing list