Ensure gaslist is NULL terminated

If buffer copying is restricted by the buffer size in strncpy or
snprintf, the copied string is not NULL terminated.  Add one to the end
just to make sure.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Miika Turkia 2014-01-11 10:17:13 +02:00 committed by Dirk Hohndel
parent 9fca37acec
commit f43a3052cb

View file

@ -365,5 +365,7 @@ char *get_gaslist(struct dive *dive)
}
if (*buf == '\0')
strncpy(buf, translate("gettextFromC","air"), MAXBUF);
buf[MAXBUF - 1] = '\0';
return buf;
}