From 77860ec6436d1537a900516fdf4e2092cd11946d Mon Sep 17 00:00:00 2001 From: AbelPau Date: Wed, 17 Apr 2024 08:57:59 +0200 Subject: [PATCH] Making safer a strcpy + eliminating an invalid comment --- ogr/ogrsf_frmts/miramon/mm_gdal_functions.c | 5 ++++- ogr/ogrsf_frmts/miramon/ogrmiramonlayer.cpp | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ogr/ogrsf_frmts/miramon/mm_gdal_functions.c b/ogr/ogrsf_frmts/miramon/mm_gdal_functions.c index 9210ce5026a5..688ed913c373 100644 --- a/ogr/ogrsf_frmts/miramon/mm_gdal_functions.c +++ b/ogr/ogrsf_frmts/miramon/mm_gdal_functions.c @@ -2407,7 +2407,10 @@ int MM_SecureCopyStringFieldValue(char **pszStringDst, const char *pszStringSrc, (*pszStringDst) = new_ptr; *nStringCurrentLength = (MM_EXT_DBF_N_FIELDS)(strlen(pszStringSrc) + 1); } - strcpy(*pszStringDst, pszStringSrc); + if (*pszStringSrc == '\0') + *pszStringDst = '\0'; + else + strcpy(*pszStringDst, pszStringSrc); return 0; } diff --git a/ogr/ogrsf_frmts/miramon/ogrmiramonlayer.cpp b/ogr/ogrsf_frmts/miramon/ogrmiramonlayer.cpp index b894f85b3be6..f2ad8344d88d 100644 --- a/ogr/ogrsf_frmts/miramon/ogrmiramonlayer.cpp +++ b/ogr/ogrsf_frmts/miramon/ogrmiramonlayer.cpp @@ -2365,7 +2365,6 @@ OGRErr OGRMiraMonLayer::TranslateFieldsValuesToMM(OGRFeature *poFeature) hMMFeature.pRecords[0].nNumField)) return OGRERR_NOT_ENOUGH_MEMORY; - // MiraMon encoding is ISO 8859-1 (Latin1) -> Recode from UTF-8 if (MM_SecureCopyStringFieldValue( &hMMFeature.pRecords[0].pField[iField].pDinValue, pszRawValue,