Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make warning #7

Open
GoogleCodeExporter opened this issue Mar 14, 2015 · 2 comments
Open

make warning #7

GoogleCodeExporter opened this issue Mar 14, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?

1.make

What is the expected output? What do you see instead?

openzwave-control-panel-read-only/webserver.cpp:333: warning: the use of 
`mktemp' is dangerous, better use `mkstemp' or `mkdtemp'

What version of the product are you using? On what operating system?
ubuntu 10.04   openzwave r603



Original issue reported on code.google.com by [email protected] on 28 Dec 2012 at 4:03

@rfdrake
Copy link

rfdrake commented Jul 18, 2015

I was looking at this code to see why it was using mktemp, but it looks like it has a couple of issues:

    strncpy(fntemp, "/tmp/ozwcp.topo.XXXXXX", sizeof(fntemp));
    fn = mktemp(fntemp);
    if (fn == NULL)
            return EMPTY;
    strncat(fntemp, ".xml", sizeof(fntemp));
    if (debug)
            doc.Print(stdout, 0);
    doc.SaveFile(fn);
    return fn;

The strncat ".xml" is never used so it should probably just be dropped. Modifying the temporary filename doesn't seem like a great idea anyway. So the other problem is that fn is a char pointer where mkstemp needs an integer since it returns a filehandle instead of a name.

That's no big deal because mkstemp will modify the buffer internally and return it.

You've got an unneeded filehandle returned, but you can deal with that in a couple of ways. You could modify doc.Savefile to accept descriptors instead of names, or just close it.

@Fishwaldo Fishwaldo self-assigned this Jul 20, 2015
@Fishwaldo
Copy link
Member

thanks. I'll look into this eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants