diff options
| author | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2015-10-14 17:28:36 -0400 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2015-10-17 14:17:50 +0200 |
| commit | b9fe7472186b8d37f16aa6b7c6039e26b49cf6e4 (patch) | |
| tree | bd1e7dde4a1775a1f9aea370c81a60c86bd07d12 | |
| parent | 0742275cb19b1c8f5f35eb34ae13e24df658fb81 (diff) | |
| download | PROJ-4.9.2-maintenance.tar.gz PROJ-4.9.2-maintenance.zip | |
Avoid strcpy of overlapping strings.4.9.2-maintenance
The source and destination for strcpy must not overlap, and failure to
ensure that's true causes a crash on OS X. memmove does not have such a
restriction.
| -rw-r--r-- | src/rtodms.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/rtodms.c b/src/rtodms.c index abf6bc1c..0f64b3d6 100644 --- a/src/rtodms.c +++ b/src/rtodms.c @@ -57,13 +57,15 @@ rtodms(char *s, double r, int pos, int neg) { (void)sprintf(ss,format,deg,min,sec,sign); else if (sec) { char *p, *q; + /* double prime + pos/neg suffix (if included) + NUL */ + size_t suffix_len = sign ? 3 : 2; (void)sprintf(ss,format,deg,min,sec,sign); - for (q = p = ss + strlen(ss) - (sign ? 3 : 2); *p == '0'; --p) ; + for (q = p = ss + strlen(ss) - suffix_len; *p == '0'; --p) ; if (*p != '.') ++p; if (++q != p) - (void)strcpy(p, q); + (void)memmove(p, q, suffix_len); } else if (min) (void)sprintf(ss,"%dd%d'%c",deg,min,sign); else |
