mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-15 04:24:28 +00:00
common initializer: fix out of buffer access by the version info string.
String must be finished at termination charactor, previous logic missed that handling, now fixed. @Issue: https://github.com/Samsung/thorvg/issues/690
This commit is contained in:
parent
b0c23451f9
commit
191442c7ae
1 changed files with 3 additions and 0 deletions
|
@ -50,18 +50,21 @@ static bool _buildVersionInfo()
|
||||||
x = strchr(p, '.');
|
x = strchr(p, '.');
|
||||||
if (!x) return false;
|
if (!x) return false;
|
||||||
strncpy(major, p, x - p);
|
strncpy(major, p, x - p);
|
||||||
|
major[x - p] = '\0';
|
||||||
p = x + 1;
|
p = x + 1;
|
||||||
|
|
||||||
char minor[3];
|
char minor[3];
|
||||||
x = strchr(p, '.');
|
x = strchr(p, '.');
|
||||||
if (!x) return false;
|
if (!x) return false;
|
||||||
strncpy(minor, p, x - p);
|
strncpy(minor, p, x - p);
|
||||||
|
minor[x - p] = '\0';
|
||||||
p = x + 1;
|
p = x + 1;
|
||||||
|
|
||||||
char micro[3];
|
char micro[3];
|
||||||
x = SRC + strlen(THORVG_VERSION_STRING);
|
x = SRC + strlen(THORVG_VERSION_STRING);
|
||||||
if (!x) return false;
|
if (!x) return false;
|
||||||
strncpy(micro, p, x - p);
|
strncpy(micro, p, x - p);
|
||||||
|
micro[x - p] = '\0';
|
||||||
|
|
||||||
char sum[7];
|
char sum[7];
|
||||||
snprintf(sum, sizeof(sum), "%s%s%s", major, minor, micro);
|
snprintf(sum, sizeof(sum), "%s%s%s", major, minor, micro);
|
||||||
|
|
Loading…
Add table
Reference in a new issue