From 9d53a9e120b3468128f59f24d1bc8253f607bf0a Mon Sep 17 00:00:00 2001 From: shahramn Date: Fri, 10 May 2024 12:35:43 +0100 Subject: [PATCH] Compiler warnings re sprintf --- fortran/grib_fortran.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fortran/grib_fortran.c b/fortran/grib_fortran.c index 3cb17739a..f5427df83 100644 --- a/fortran/grib_fortran.c +++ b/fortran/grib_fortran.c @@ -986,7 +986,7 @@ void grib_f_write_on_fail(int* gid) { file_count++; GRIB_MUTEX_UNLOCK(&handle_mutex) - sprintf(filename,"%ld_%d_error.grib",(long)pid,file_count); + snprintf(filename, sizeof(filename), "%ld_%d_error.grib",(long)pid,file_count); h=get_handle(*gid); if (h) grib_write_message(h,filename,"w"); @@ -1249,7 +1249,7 @@ int grib_f_keys_iterator_get_name_(int* iterid,char* name,int len) fort_char_clean(name, len); - sprintf(buf,"%s",grib_keys_iterator_get_name(kiter)); + snprintf(buf, sizeof(buf), "%s",grib_keys_iterator_get_name(kiter)); lsize = strlen(buf); if (input_len < lsize) return GRIB_ARRAY_TOO_SMALL; @@ -1321,7 +1321,7 @@ int codes_f_bufr_keys_iterator_get_name_(int* iterid, char* name, int len) fort_char_clean(name, len); - sprintf(buf, "%s", codes_bufr_keys_iterator_get_name(kiter)); + snprintf(buf, sizeof(buf), "%s", codes_bufr_keys_iterator_get_name(kiter)); lsize = strlen(buf); if (input_len < lsize) return GRIB_ARRAY_TOO_SMALL;