From c102546beef68ad1828d9fe763656cfe656ef982 Mon Sep 17 00:00:00 2001 From: Adiel Mittmann Date: Fri, 3 Nov 2017 15:00:33 -0200 Subject: [PATCH] When the value was too large, I was getting this error: *** stack smashing detected ***: terminated Now the value is truncated when it is too large. --- nvp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nvp.c b/nvp.c index 04e2087..81aef8f 100644 --- a/nvp.c +++ b/nvp.c @@ -153,6 +153,7 @@ struct nvp *make_nvp(struct msg_src *src, char *s, const char *pfx)/*{{{*/ struct nvp *result; size_t pfxlen; char *nn, *mm, *vv; + char *vv_null_pos; pfxlen = strlen(pfx); if (strncasecmp(pfx, s, pfxlen)) @@ -168,6 +169,7 @@ struct nvp *make_nvp(struct msg_src *src, char *s, const char *pfx)/*{{{*/ nn = name; mm = minor; vv = value; + vv_null_pos = value + sizeof(value) - 1; last_action = GOT_NOTHING; do { qq = *(unsigned char *) q; @@ -211,6 +213,7 @@ struct nvp *make_nvp(struct msg_src *src, char *s, const char *pfx)/*{{{*/ #ifdef VERBOSE_TEST fprintf(stderr, " COPY_TO_VALUE\n"); #endif + if (vv < vv_null_pos) *vv++ = *q; break; case COPY_NOWHERE: