1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-28 06:03:25 +00:00

Converted atoi to safer alternative

This commit is contained in:
Bryan Roe
2020-09-24 15:50:27 -07:00
parent 600758ff8d
commit 73b1d5e77c
9 changed files with 105 additions and 40 deletions

View File

@@ -1638,10 +1638,10 @@ duk_ret_t ILibDuktape_ScriptContainer_OS_arch(duk_context *ctx)
}
else
{
int mlen = strlen(u.machine);
int mlen = strlen(u.machine); // size is not specified, but is gauranteed to be NULL terminated
if (mlen > 4 && strncmp(u.machine, "armv", 4) == 0)
{
if (atoi(u.machine + 4) > 7)
if (ILib_atoi2_int32(u.machine + 4, mlen) > 7)
{
duk_push_string(ctx, "arm64");
}

View File

@@ -2134,7 +2134,7 @@ duk_ret_t ILibDuktape_TLS_connect(duk_context *ctx)
if (pct > 0)
{
hostCopy[pct] = 0;
pct = atoi(hostCopy + pct + 1);
pct = ILib_atoi2_int32(hostCopy + pct + 1, sizeof(hostCopy));
}
else
{

View File

@@ -156,7 +156,7 @@ int ILibDuktape_EventEmitter_HasListeners2(ILibDuktape_EventEmitter *emitter, ch
{
memcpy_s(numtmp, sizeof(numtmp), pr2->LastResult->data, pr2->LastResult->datalength);
numtmp[pr2->LastResult->datalength] = 0;
retVal = atoi(numtmp);
retVal = ILib_atoi2_int32(numtmp, sizeof(numtmp));
ILibDestructParserResults(pr2);
break;
}