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

Corrupt error handling in dlp_VFSDirEntryEnumerate in dlp.c #9

Open
CoSoCo opened this issue Aug 15, 2022 · 1 comment
Open

Corrupt error handling in dlp_VFSDirEntryEnumerate in dlp.c #9

CoSoCo opened this issue Aug 15, 2022 · 1 comment

Comments

@CoSoCo
Copy link

CoSoCo commented Aug 15, 2022

Because result is defined as unsigned, it will never be negative. So the code after if (result > 0) becomes always executed, even on negative error result from dlp_exec (sd, req, &res). So result should be defined signed int. Compare with similar function dlp_VFSVolumeEnumerate().

Additionally, the else part of the later if (result) will never be reached, as result will always be non-zero at this branch.

int
dlp_VFSDirEntryEnumerate(int sd, FileRef dirRefNum, 
	unsigned long *dirIterator, int *maxDirItems, struct VFSDirInfo *data)
{
	unsigned int result,
[.....]
	result = dlp_exec (sd, req, &res);
[.....]
	if (result > 0) {
		if (result) {
			*dirIterator = get_long (DLP_RESPONSE_DATA (res, 0, 0));
			entries = get_long (DLP_RESPONSE_DATA (res, 0, 4));
		} else {
			*dirIterator = vfsIteratorStop;
			entries = 0;
		}
[.....]
@CoSoCo
Copy link
Author

CoSoCo commented Aug 15, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant