aboutsummaryrefslogtreecommitdiff
path: root/src/proj_4D_api.c
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2018-03-12 20:19:59 +0100
committerEven Rouault <even.rouault@spatialys.com>2018-03-12 20:19:59 +0100
commit718495c62ed00d6bf2a60be3b67ecf7e2e8da2d2 (patch)
treeb7a55303edd7f29b76a8287df96dfaaef6a87471 /src/proj_4D_api.c
parentb9f890052974ac0e71221a48f32e1af24bf79894 (diff)
downloadPROJ-718495c62ed00d6bf2a60be3b67ecf7e2e8da2d2.tar.gz
PROJ-718495c62ed00d6bf2a60be3b67ecf7e2e8da2d2.zip
Fix 'bufferAccessOutOfBounds,Buffer is accessed out of bounds' cppcheck warnings
Diffstat (limited to 'src/proj_4D_api.c')
-rw-r--r--src/proj_4D_api.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/proj_4D_api.c b/src/proj_4D_api.c
index f96dd67d..3ad124e5 100644
--- a/src/proj_4D_api.c
+++ b/src/proj_4D_api.c
@@ -632,14 +632,18 @@ PJ *proj_create_crs_to_crs (PJ_CONTEXT *ctx, const char *srid_from, const char
******************************************************************************/
PJ *P;
char buffer[512];
+ size_t len;
/* area not in use yet, suppressing warning */
(void)area;
strcpy(buffer, "+proj=pipeline +step +init=");
- strncat(buffer, srid_from, 512-strlen(buffer));
- strncat(buffer, " +inv +step +init=", 512-strlen(buffer));
- strncat(buffer, srid_to, 512-strlen(buffer));
+ len = strlen(buffer);
+ strncat(buffer + len, srid_from, sizeof(buffer)-1-len);
+ len += strlen(buffer + len);
+ strncat(buffer + len, " +inv +step +init=", sizeof(buffer)-1-len);
+ len += strlen(buffer + len);
+ strncat(buffer + len, srid_to, sizeof(buffer)-1-len);
P = proj_create(ctx, buffer);
@@ -1004,7 +1008,7 @@ PJ_INIT_INFO proj_init_info(const char *initname){
key[64] = 0;
strncat(key, ":metadata", 9);
strcpy(param, "+init=");
- strncat(param, key, 73);
+ strncat(param + strlen(param), key, sizeof(param)-1-strlen(param));
start = pj_mkparam(param);
pj_expand_init(ctx, start);