Bug 535976 - Reading of PHAR signature is done wrongly
Summary: Reading of PHAR signature is done wrongly
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: PHP Core CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-17 07:09 EDT by Rafal Stanczak CLA
Modified: 2020-05-14 11:25 EDT (History)
2 users (show)

See Also:


Attachments
Propsed patch to PharFile.java and PharUtil.java (6.43 KB, patch)
2018-06-17 07:09 EDT, Rafal Stanczak CLA
no flags Details | Diff
problematic phar file (33.60 KB, application/octet-stream)
2018-06-17 07:11 EDT, Rafal Stanczak CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafal Stanczak CLA 2018-06-17 07:09:50 EDT
Created attachment 274482 [details]
Propsed patch to PharFile.java and PharUtil.java

Reading of PHAR file signature is done wrong.

In phar.c (https://github.com/php/php-src/blob/master/ext/phar/phar.c) the reading of signature is done from the end of file (line 767 of phar.c).
In the PharFile.java the signature is readed from the position of the last file (+ its size).

This couses problems with reading and comparing of digest hash.

patch for PharFile.java and PharUtil.java in attachement.

Problematic phar input file in https://dev.pregusia.pl/pdt_bug/sample_phar_file.phar (I wasnt able to add more than one attachment)


Steps to reproduce:
 1. Create empty PHP project
 2. try to add given phar file into include path
Comment 1 Rafal Stanczak CLA 2018-06-17 07:11:41 EDT
Created attachment 274483 [details]
problematic phar file
Comment 2 Michal Niewrzal CLA 2018-06-17 07:54:22 EDT
Thanks for bug report and patch. We are only able to use patches contributed via Gerrit. Do you think you will be able to send us your patch with Gerrit?

All necessary info on how to do this you can find here:
https://wiki.eclipse.org/PDT/Contributing

We will help in case of any problem.
Comment 3 Rafal Stanczak CLA 2018-06-17 09:09:46 EDT
(In reply to Michal Niewrzal from comment #2)
> Thanks for bug report and patch. We are only able to use patches contributed
> via Gerrit. Do you think you will be able to send us your patch with Gerrit?
> 
> All necessary info on how to do this you can find here:
> https://wiki.eclipse.org/PDT/Contributing
> 
> We will help in case of any problem.

Thanks for reply & tutorial.
I've managed to install Eclipse commiters edition, import all git pdt repos, make changes and... I'think i commited changes to GIT repo, but when I was trying to push I've got:

> Repository ssh://....@git.eclipse.org:29418/pdt/org.eclipse.pdt.git
> 
> prohibited by Gerrit: ref update access denied
> Branch refs/heads/master:
> You are not allowed to perform this operation.
> To push into this reference you need 'Push' rights.
> User: ....
> Please read the documentation and contact an administrator
> if you feel the configuration is incorrect

So, finnaly I dont know if I've done it in proper way - I've never used git ;p
Comment 4 Dawid Pakula CLA 2018-06-17 09:16:13 EDT
Repo URL is ssh://....@git.eclipse.org:29418/pdt/org.eclipse.pdt.git where "..." username available on accounts.eclipse.org (in top after "welcome,".

Similar to github, you need upload RSA public key to gerrit (.ssh/id_rsa.pub) : https://git.eclipse.org/r/#/settings/ssh-keys

If you haven't any just run ssh-keygen.
Comment 5 Rafal Stanczak CLA 2018-06-17 09:21:55 EDT
(In reply to Dawid Pakula from comment #4)
> Repo URL is ssh://....@git.eclipse.org:29418/pdt/org.eclipse.pdt.git where
> "..." username available on accounts.eclipse.org (in top after "welcome,".
> 
> Similar to github, you need upload RSA public key to gerrit
> (.ssh/id_rsa.pub) : https://git.eclipse.org/r/#/settings/ssh-keys
> 
> If you haven't any just run ssh-keygen.

I've created key-pair, uploaded it to https://git.eclipse.org/r/#/settings/ssh-keys and URL is correct (after all I've cloned repo to my local computer).
Comment 6 Dawid Pakula CLA 2018-06-17 09:25:46 EDT
Try this command: git push origin HEAD:refs/for/master
Comment 7 Rafal Stanczak CLA 2018-06-17 09:35:08 EDT
(In reply to Dawid Pakula from comment #6)
> Try this command: git push origin HEAD:refs/for/master

OK, from CLI it goes better, but now I've got

> remote: Resolving deltas: 100% (7/7)
> remote: Processing changes: refs: 1, done    
> remote: (W) 41dec4b: commit subject >50 characters; use shorter first paragraph
> remote: ----------
> remote: Reviewing commit: 41dec4be
> remote: Authored by: Rafal Stanczak <rafal@pregusia.pl>
> remote: 
> remote: The author is not a committer on the project.
> remote: error: The author does not have a current Eclipse Contributor Agreement (ECA) on file.
> remote: If there are multiple commits, please ensure that each author has a ECA.
> remote: 
> remote: The author has "signed-off" on the contribution.
> remote: Please see http://wiki.eclipse.org/ECA

But I've already signed ECA in accounts.eclipse.org
"The Eclipse Contributor Agreement that we have on record for you will expire on 2021-06-17."

;s
Comment 8 Dawid Pakula CLA 2018-06-17 09:42:55 EDT
We are close ;) Eclipse says you sign ECA (https://accounts.eclipse.org/user/eca) can you check this?

Also make sure Signed-Off in commit message (if exists) have same mail.

Another problem might if you prepared more than one commit (check via `git log`).
Comment 9 Rafal Stanczak CLA 2018-06-17 09:48:34 EDT
(In reply to Dawid Pakula from comment #8)
> We are close ;) Eclipse says you sign ECA
> (https://accounts.eclipse.org/user/eca) can you check this?
> 
> Also make sure Signed-Off in commit message (if exists) have same mail.
> 
> Another problem might if you prepared more than one commit (check via `git
> log`).

As I said, on accounts.eclipse.org it shows that I've signed ECA.
I'm trying to make only one commit (already checked git log and git show)
E-mails are the-same in Author/Signed-off-by fields.
Comment 10 Eclipse Genie CLA 2018-06-17 10:14:03 EDT
New Gerrit change created: https://git.eclipse.org/r/124645
Comment 11 Rafal Stanczak CLA 2018-06-17 10:27:47 EDT
Ok, it has finally worked ^^
Thanks for help :)
Comment 13 Dawid Pakula CLA 2018-06-19 10:34:11 EDT
Thank You!