Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Subtle bug: checking against the wrong CreateJobObject return value #5

@ariccio

Description

@ariccio

I'm screwing around with /analyze, and it's picked up a couple of issues for AppJailLauncher. Good software development on your part means this bug won't cause any bad behavior, but you might be confused if you're debugging.

At line 344 in utils.cpp you check the return value of CreateJobObject against INVALID_HANDLE_VALUE:

	hJob = CreateJobObject(NULL, NULL);
	W32_ASSERT(hJob != INVALID_HANDLE_VALUE, Exit);
	LOG("New job object created with handle %016p\n", hJob);

...but the docs say CreateJobObject returns NULL on failure:

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

When CreateJobObject fails and you don't catch it here, it's not a big deal, because SetInformationJobObject should also fail. Because you properly check that return value, CreateLimitProcessTimeJobObject then returns E_FAIL, and the program exits with -1.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions