Commit 7d91984fe9bd7a4fcd3d1d73887cd5f35c4fb09f
1 parent
89681d24
Use mkstemp() instead of tmpnam().
Fixes #1072. Before, the following warning was generated: warning: 'tmpnam' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of tmpnam(3), it is highly recommended that you use mkstemp(3) instead.
Showing
1 changed file
with
11 additions
and
5 deletions
src/ctselect/ctselect.cpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * ctselect - CTA data selection tool * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2010-2013 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2010-2014 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -28,13 +28,13 @@ |
| 28 | 28 | #ifdef HAVE_CONFIG_H |
| 29 | 29 | #include <config.h> |
| 30 | 30 | #endif |
| 31 | -#include <cstdio> | |
| 31 | +#include <cstdlib> | |
| 32 | 32 | #include "ctselect.hpp" |
| 33 | 33 | #include "GTools.hpp" |
| 34 | 34 | |
| 35 | 35 | /* __ Method name definitions ____________________________________________ */ |
| 36 | 36 | #define G_RUN "ctselect::run()" |
| 37 | -#define G_SELECT_EVENTS "ctselect::select_events(GCTAObservation*,"\ | |
| 37 | +#define G_SELECT_EVENTS "ctselect::select_events(GCTAObservation*, "\ | |
| 38 | 38 | "std::string&)" |
| 39 | 39 | |
| 40 | 40 | /* __ Debug definitions __________________________________________________ */ |
| ... | ... | @@ -291,7 +291,10 @@ void ctselect::run(void) |
| 291 | 291 | m_infiles[i] = obs->eventfile(); |
| 292 | 292 | |
| 293 | 293 | // Get temporary file name |
| 294 | - std::string filename = std::tmpnam(NULL); | |
| 294 | + //std::string filename = std::tmpnam(NULL); | |
| 295 | + char tpl[] = "ctselectXXXXXX"; | |
| 296 | + mkstemp(tpl); | |
| 297 | + std::string filename(tpl); | |
| 295 | 298 | |
| 296 | 299 | // Save observation in temporary file |
| 297 | 300 | obs->save(filename, true); |
| ... | ... | @@ -626,7 +629,10 @@ void ctselect::select_events(GCTAObservation* obs, const std::string& filename) |
| 626 | 629 | else { |
| 627 | 630 | |
| 628 | 631 | // Get temporary file name |
| 629 | - std::string tmpname = std::tmpnam(NULL); | |
| 632 | + //std::string tmpname = std::tmpnam(NULL); | |
| 633 | + char tpl[] = "ctselectXXXXXX"; | |
| 634 | + mkstemp(tpl); | |
| 635 | + std::string tmpname(tpl); | |
| 630 | 636 | |
| 631 | 637 | // Save FITS file to temporary file |
| 632 | 638 | file.saveto(tmpname, true); | ... | ... |