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:
parent
9451f29440
commit
0606189269
1 changed files with 5 additions and 1 deletions
6
semver.c
6
semver.c
|
@ -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;
|
||||||
|
|
Loading…
Add table
Reference in a new issue