Make parsePreRelease copy the original string into a fixed width

buffer so it avoids modifying the original string via `strntok` or
similar
This commit is contained in:
Nathan Fisher 2024-02-12 12:20:29 -05:00
parent 9451f29440
commit 0606189269

View file

@ -130,8 +130,12 @@ int parseGitRev(char *vp, GitRevision *git) {
int parsePreRelease(PreRelease *pr, char *s) { int parsePreRelease(PreRelease *pr, char *s) {
PreReleaseTag tag; PreReleaseTag tag;
long val = 0; long val = 0;
char *vp; char v[50];
char *vp = (char *)v;
ssize_t len = strnlen(s, 52);
if (len > 50) return 1;
memcpy(s, vp, len);
if (strncasecmp(s, "alpha", 5) == 0) { if (strncasecmp(s, "alpha", 5) == 0) {
tag = Alpha; tag = Alpha;
vp = s + 5; vp = s + 5;