ECC-1468: Replace all instances of the deprecated function 'sprintf' with 'snprintf'

This commit is contained in:
Shahram Najm 2022-11-10 12:46:18 +00:00
parent a27cdb1634
commit 5a2738b211
2 changed files with 4 additions and 4 deletions

View File

@ -2035,7 +2035,7 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr
return NULL;
grib_accessor_add_attribute(elementAccessor, attribute, 0);
sprintf(code, "%06ld", self->expanded->v[idx]->code);
snprintf(code, sizeof(code), "%06ld", self->expanded->v[idx]->code);
temp_str = grib_context_strdup(a->context, code);
attribute = create_attribute_variable("code", section, GRIB_TYPE_STRING, temp_str, 0, 0, flags);
if (!attribute)
@ -2095,7 +2095,7 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr
return NULL;
grib_accessor_add_attribute(elementAccessor, attribute, 0);
sprintf(code, "%06ld", self->expanded->v[idx]->code);
snprintf(code, sizeof(code), "%06ld", self->expanded->v[idx]->code);
attribute = create_attribute_variable("code", section, GRIB_TYPE_STRING, code, 0, 0, flags);
if (!attribute)
return NULL;
@ -2121,7 +2121,7 @@ static grib_accessor* create_accessor_from_descriptor(const grib_accessor* a, gr
return NULL;
grib_accessor_add_attribute(elementAccessor, attribute, 0);
sprintf(code, "%06ld", self->expanded->v[idx]->code);
snprintf(code, sizeof(code), "%06ld", self->expanded->v[idx]->code);
attribute = create_attribute_variable("code", section, GRIB_TYPE_STRING, code, 0, 0, flags);
if (!attribute)
return NULL;

View File

@ -24,7 +24,7 @@ void grib_vdarray_print(const char* title, const grib_vdarray* vdarray)
Assert(vdarray);
printf("%s: vdarray.n=%lu\n", title, (unsigned long)vdarray->n);
for (i = 0; i < vdarray->n; i++) {
sprintf(text, " vdarray->v[%lu]", (unsigned long)i);
snprintf(text, sizeof(text), " vdarray->v[%lu]", (unsigned long)i);
grib_darray_print(text, vdarray->v[i]);
}
printf("\n");