Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libpromises/evalfunction: Do not crash w/o arguments #5630

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions libpromises/evalfunction.c
Original file line number Diff line number Diff line change
Expand Up @@ -5730,6 +5730,14 @@ static FnCallResult FnCallFormat(EvalContext *ctx, ARG_UNUSED const Policy *poli
static FnCallResult FnCallIPRange(EvalContext *ctx, ARG_UNUSED const Policy *policy,
const FnCall *fp, const Rlist *finalargs)
{
assert(fp != NULL);

if (finalargs == NULL)
{
Log(LOG_LEVEL_ERR, "Function '%s' requires at least one argument", fp->name);
Fixed Show fixed Hide fixed
return FnFailure();
}

const char *range = RlistScalarValue(finalargs);
const Rlist *ifaces = finalargs->next;

Expand Down Expand Up @@ -5794,6 +5802,14 @@ static FnCallResult FnCallIsIpInSubnet(ARG_UNUSED EvalContext *ctx,
ARG_UNUSED const Policy *policy,
const FnCall *fp, const Rlist *finalargs)
{
assert(fp != NULL);

if (finalargs == NULL)
{
Log(LOG_LEVEL_ERR, "Function '%s' requires at least one argument", fp->name);
Fixed Show fixed Hide fixed
return FnFailure();
}

const char *range = RlistScalarValue(finalargs);
const Rlist *ips = finalargs->next;

Expand Down Expand Up @@ -6911,6 +6927,12 @@ static FnCallResult FnCallEval(EvalContext *ctx, ARG_UNUSED const Policy *policy

static FnCallResult FnCallReadFile(ARG_UNUSED EvalContext *ctx, ARG_UNUSED const Policy *policy, ARG_UNUSED const FnCall *fp, const Rlist *finalargs)
{
if (finalargs == NULL)
{
Log(LOG_LEVEL_ERR, "Function 'readfile' requires at least one argument");
return FnFailure();
}

char *filename = RlistScalarValue(finalargs);
const Rlist *next = finalargs->next; // max_size argument, default to inf:
long maxsize = next ? IntFromString(RlistScalarValue(next)) : IntFromString("inf");
Expand Down
Loading