From de85d9c7942c07f0c5408ab08a88dd8c0c926a4f Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Wed, 3 Oct 2012 19:10:40 +0000 Subject: [PATCH] Add protected against empty binary file and disable all binary file support. If a file is empty, it's not a binary file in the first place. This is to protect against improper uploads. From light testing, it seems binary file support is totally broken. This needs to be verified throughout before being enabled back. TBR=rogerta@chromium.org BUG=23608 Review URL: https://chromiumcodereview.appspot.com/11016032 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@159941 0039d316-1c4b-4281-b951-d872f2087c98 --- rietveld.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/rietveld.py b/rietveld.py index e0bd7a54a..a03fe77e3 100644 --- a/rietveld.py +++ b/rietveld.py @@ -136,11 +136,24 @@ class Rietveld(object): filename, 'Deleted file shouldn\'t have property change.') out.append(patch.FilePatchDelete(filename, state['is_binary'])) else: - out.append(patch.FilePatchBinary( + content = self.get_file_content(issue, patchset, state['id']) + if not content: + # As a precaution due to a bug in upload.py for git checkout, refuse + # empty files. If it's empty, it's not a binary file. + raise patch.UnsupportedPatchFormat( + filename, + 'Binary file is empty. Maybe the file wasn\'t uploaded in the ' + 'first place?') + raise patch.UnsupportedPatchFormat( filename, - self.get_file_content(issue, patchset, state['id']), - svn_props, - is_new=(status[0] == 'A'))) + 'Binary file support is temporarilly disabled due to a bug. ' + 'Please commit blindly the binary files first then commit the ' + 'source change as a separate CL. Sorry for the annoyance.') + #out.append(patch.FilePatchBinary( + # filename, + # content, + # svn_props, + # is_new=(status[0] == 'A'))) continue try: