View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000742 | PHP for OS/2, ArcaOS & eComStation (PHP versions v8.x v7.x v5.x) | Bug | public | 2022-02-16 19:19 | 2022-05-25 04:10 |
Reporter | emax | Assigned To | psmedley | ||
Priority | normal | Severity | block | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | SuperMicro server Xeon 4 core | OS | ecs 2.1 with AN drv package | OS Version | 2.1 |
Summary | 0000742: Php 7.4.27 issue with attachments in Roundcube webmail | ||||
Description | Server Version: Apache/2.4.52 (OS/2) OpenSSL/1.1.1m Server Built: Dec 28 2021 08:13:42 Server loaded APR Version: 1.7.0 Compiled with APR Version: 1.7.0 Server loaded APU Version: 1.6.1 Compiled with APU Version: 1.6.1 Build: httpd-2.4.52-os2-20211228-debug.zip when running PHP 7.4.27, this build: php-7.4.27-os2-20220124.zip in Roundcube webmail version 1.3.17 (Long term service) https://roundcube.net/download/ attachments to new emails get corrupted (every kind of format, jpeg, xlsx, docx, zip etc.) | ||||
Steps To Reproduce | they get corrupted after uploading them to the webmail you don't need to send the new email, even if you download the uploaded attachment before sending out the email, it's already corrupted | ||||
Additional Information | i had to revert back to php 5.6.40 to have the function working again on this machine i don't run YUM, but libcx DLLs are manually updated and are the same like in the other servers where i run YUM to keep them updated | ||||
Tags | No tags attached. | ||||
|
Can you try with https://smedley.id.au/tmp/php-7.4.27-os2-20220216.zip ? I found a win32 call that uses O_BINARY in ext\standard\proc_open.c that probably needs to be run on OS/2. |
|
thanks tried, it unfortunately the issue is still here i had to revert to 5.6.40 again |
|
Thanks for the quick feedback. Are you able to confirm the test code at https://www.w3schools.com/php/php_file_upload.asp is sufficient to reproduce this? |
|
the script do not seems to work at all when i choose a file to upload and i click the upload button it say "nessun file scelto" (no file choosen).. the 2nd script just show a white (empty) page with no errors in php.log <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } ?> |
|
please erase note: 003905 i had to create upload.html and upload.php, not it seems do something when i upload a image (jpeg) it say this: File is an image - image/jpeg. but, it do not anything more is this ok? |
|
sorry, delete also note 0003906 i had to use the complete php scritp now it uploaded the image and it get corrupted in the same way like it happens on the webmail yes, it happens the same |
|
Massimo, I think it would be wise to check that the uploaded temporary file is not corrupted. From the script that Paul pointed you to, we see the file name is stored in $_FILES["fileToUpload"]["tmp_name"] so replace the lines that read: if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded."; } else { echo "Sorry, there was an error uploading your file."; } with echo 'tmp_name is ' . $_FILES["fileToUpload"]["tmp_name"]; Barring typos, the name of the temporary file will be displayed. Then verify that the temporary file is not corrupted. |
|
as wrote in the note 3907 the file uploaded get corrupted (i add in the same way it happens in the webmail) i've verified |
|
Massimo, I asked you to verify the temporary file. Did you do this? |
|
i'm running this script: <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } // Check if file already exists if (file_exists($target_file)) { echo "Sorry, file already exists."; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 500000) { echo "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded."; } else { echo "Sorry, there was an error uploading your file."; } } ?> |
|
I already know what script you are running. Did you not understand what I asked you to do? When running php 5.6.40, are you using the same roundcube version as fails for 7.4.27? |
|
When running php 5.6.40, are you using the same roundcube version as fails for 7.4.27? yes, of course: Roundcube webmail version 1.3.17 (Long term service) |
|
you still need the temporary file upload test? let me know, please |
|
I would not have asked you to check the temporary file unless I knew it would be a useful to check. It should be obvious that the result will give us a better idea where the problem starts. |
|
"with echo 'tmp_name is ' . $_FILES["fileToUpload"]["tmp_name"]; Barring typos, the name of the temporary file will be displayed. Then verify that the temporary file is not corrupted." Done i've tried it on php 5.6.40, but it save no temporary file at all, it just display on screen "File is an image - image/jpeg.tmp_name is X:\temp/phpCfTJuc" but if i go to X:\temp the dir is empty i will try with php 7.4.27 |
|
This is not the expected result. The file must have existed or it would never have gotten moved to the uploads directory. Perhaps, php is deleting the file when the script finishes. It knows it is a temporary file. Let's replace the echo line with: echo ' tmp_name is ' . $_FILES["fileToUpload"]["tmp_name"]; sleep(60); echo ' We are awake now.'; This will display the message on a separate line and give you 60 seconds to find the file in the X:\temp directory. Sort the directory list by date descending so you can see the most recently created files. |
|
(allways tested with 5.6.40) i confirm the behaviour after 60 seconds the temp files disappear but now it work and the file stay in temp dir for 60 seconds, this is good i will test with php 7 |
|
i've tested it with php 7.4.27 the file uploaded with the script in the temp dir is corrupted |
|
Excellent. This helps understand where the issue originates. Currently, my two possible culprits are: php_open_temporary_file.c:87 static int php_do_open_temporary_file(const char *path, const char *pfx, zend_string **opened_path_p) and main\rfc1867.c:672 SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ php_do_open_temporary_file looks like is should open the file in binary mode, but this needs to be verified. If that's not it, the issue may be in rfc1867_post_handler, which parses the form data an writes it to the temporary file. Massimo, when you get a moment, please redo the test with 8.1.2 just in case this is a 7.4 only issue. |
|
OK - for me - the file in TMP is ok. Max - please confirm you're running the 17-Feb-2022 build of php7.dll The uploaded file is also OK - also tested with PHP 8.1.2 and works for me |
|
Hi, i'm running this: https://smedley.id.au/tmp/php-7.4.27-os2-20220216.zip dll in the package: php7.dll 17.291K 16/02/22 dll in libpath: php7.dll 17.291K 16/02/22 |
|
answer to Steven: Massimo, when you get a moment, please redo the test with 8.1.2 just in case this is a 7.4 only issue. 8.1.2 don't even start here (maybe virtual hosts, or https) dunno |
|
OK maybe somehting changed on Thursday morning - https://smedley.id.au/tmp/php-7.4.27-os2-20220217.zip (this is the build i'm using) |
|
ok, with this build: https://smedley.id.au/tmp/php-7.4.27-os2-20220217.zip the issues is fixed thanks a lot, you can close the ticket |
|
Fixed in latest build |
Date Modified | Username | Field | Change |
---|---|---|---|
2022-02-16 19:19 | emax | New Issue | |
2022-02-16 19:25 | psmedley | Note Added: 0003902 | |
2022-02-16 19:26 | psmedley | Assigned To | => psmedley |
2022-02-16 19:26 | psmedley | Status | new => assigned |
2022-02-16 19:55 | emax | Note Added: 0003903 | |
2022-02-16 20:18 | psmedley | Note Added: 0003904 | |
2022-02-16 21:37 | emax | Note Added: 0003905 | |
2022-02-16 21:44 | emax | Note Added: 0003906 | |
2022-02-16 21:48 | emax | Note Added: 0003907 | |
2022-02-18 07:15 | Steven Levine | Status | assigned => feedback |
2022-02-18 07:15 | Steven Levine | Note Added: 0003908 | |
2022-02-18 07:21 | emax | Note Added: 0003909 | |
2022-02-18 07:21 | emax | Status | feedback => assigned |
2022-02-18 07:59 | Steven Levine | Status | assigned => feedback |
2022-02-18 07:59 | Steven Levine | Note Added: 0003910 | |
2022-02-18 08:32 | emax | Note Added: 0003911 | |
2022-02-18 08:32 | emax | Status | feedback => assigned |
2022-02-18 11:08 | Steven Levine | Status | assigned => feedback |
2022-02-18 11:08 | Steven Levine | Note Added: 0003912 | |
2022-02-18 17:25 | emax | Note Added: 0003913 | |
2022-02-18 17:25 | emax | Status | feedback => assigned |
2022-02-20 00:00 | emax | Note Added: 0003914 | |
2022-02-20 02:07 | Steven Levine | Status | assigned => feedback |
2022-02-20 02:07 | Steven Levine | Note Added: 0003915 | |
2022-02-20 06:34 | emax | Note Added: 0003916 | |
2022-02-20 06:34 | emax | Status | feedback => assigned |
2022-02-20 07:43 | Steven Levine | Status | assigned => feedback |
2022-02-20 07:43 | Steven Levine | Note Added: 0003917 | |
2022-02-20 07:59 | emax | Note Added: 0003919 | |
2022-02-20 07:59 | emax | Status | feedback => assigned |
2022-02-21 08:02 | emax | Note Added: 0003920 | |
2022-02-21 12:15 | Steven Levine | Note Added: 0003921 | |
2022-02-21 12:16 | Steven Levine | Status | assigned => feedback |
2022-02-21 13:59 | psmedley | Note Added: 0003922 | |
2022-02-21 14:15 | psmedley | Note Edited: 0003922 | |
2022-02-21 19:13 | emax | Note Added: 0003923 | |
2022-02-21 19:13 | emax | Status | feedback => assigned |
2022-02-21 19:14 | emax | Note Added: 0003924 | |
2022-02-21 19:31 | psmedley | Note Added: 0003925 | |
2022-02-21 20:20 | emax | Note Added: 0003926 | |
2022-02-22 17:07 | psmedley | Status | assigned => closed |
2022-02-22 17:07 | psmedley | Resolution | open => fixed |
2022-02-22 17:07 | psmedley | Note Added: 0003927 |