Skip to content

Fix compiler warnings in proc_open.c #5629

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

Closed

Conversation

alexdowad
Copy link
Contributor

These are causing compiler warnings when building in Appveyor CI. (Also slipped in a couple style and grammar tweaks.)

alexdowad added 2 commits May 26, 2020 15:34
We are getting a lot of compiler warnings when building on Appveyor CI (Windows).
Fix some of them.
@@ -794,7 +791,7 @@ static int set_proc_descriptor_from_array(zval *descitem, descriptorspec_item *d
}

retval = redirect_proc_descriptor(
&descriptors[ndesc], Z_LVAL_P(ztarget), descriptors, ndesc, nindex);
&descriptors[ndesc], (int)Z_LVAL_P(ztarget), descriptors, ndesc, nindex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to be pedantic, we can add a if (ZEND_LONG_EXCEEDS_INT(Z_LVAL_P(ztarget)) { error } check beforehand, to avoid silently truncating the value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's worth it. But if you want...

Will people will ever call proc_open with file descriptor numbers so big they don't fit in an int? Do you know any Unix kernel which allows processes to use that many file descriptors?

At other places in proc_open we also truncate the FD numbers to int. Rather than fixing it here, it would make more sense to check right at the beginning where the arguments are checked. (But as said, I don't think it's worth it.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case the issue is the other way around: Not that you might have this many file descriptors (which, as you say, is impossible), but that you could write ['redirect', 0x100000001] and have it silently behave the same as ['redirect', 1].

But as you say, probably not worth the bother. It's not like it would actually break anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. But if you want it done... just say so. I am willing.

@php-pulls php-pulls closed this in dff7994 May 27, 2020
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

Successfully merging this pull request may close these issues.

2 participants