Open GoogleCodeExporter opened 9 years ago
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.
thanks. I'll look into this eventually.
Original issue reported on code.google.com by
softgh...@gmail.com
on 28 Dec 2012 at 4:03