Jakub Filak <[email protected]> writes: > --- > src/include/internal_libreport.h | 1 + > src/lib/create_dump_dir.c | 5 +++-- > src/lib/iso_date_string.c | 2 +- > src/plugins/reporter-rhtsupport.c | 6 +++--- > 4 files changed, 8 insertions(+), 6 deletions(-) > > diff --git a/src/include/internal_libreport.h > b/src/include/internal_libreport.h > index 892a70f..42c94f7 100644 > --- a/src/include/internal_libreport.h > +++ b/src/include/internal_libreport.h > @@ -567,6 +567,7 @@ char* get_environ(pid_t pid); > */ > #define iso_date_string libreport_iso_date_string > char *iso_date_string(const time_t *pt); > +#define LIBREPORT_ISO_DATE_STRING_SAMPLE "YYYY-MM-DD-hh:mm:ss" > > enum { > MAKEDESC_SHOW_FILES = (1 << 0), > diff --git a/src/lib/create_dump_dir.c b/src/lib/create_dump_dir.c > index 27e3761..fb17d57 100644 > --- a/src/lib/create_dump_dir.c > +++ b/src/lib/create_dump_dir.c > @@ -29,8 +29,9 @@ static struct dump_dir *try_dd_create(const char > *base_dir_name, const char *dir > > struct dump_dir *create_dump_dir_from_problem_data(problem_data_t > *problem_data, const char *base_dir_name) > { > - char dir_name[sizeof("abrt-tmp-YYYY-MM-DD-HH:MM:SS-%lu") + > sizeof(long)*3]; > - sprintf(dir_name, "abrt-tmp-%s-%lu", iso_date_string(NULL), > (long)getpid()); > + const size_t > tmp_required_size=sizeof("abrt-tmp-"LIBREPORT_ISO_DATE_STRING_SAMPLE"-%lu") + > sizeof(long)*3; > + char dir_name[tmp_required_size]; > + snprintf(dir_name, tmp_required_size, "abrt-tmp-%s-%lu", > iso_date_string(NULL), (long)getpid()); >
you can use simply snprintf(dir_name, sizeof(dir_name), ...) -- Nikola
