Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2900)

Unified Diff: chrome/test/data/extensions/unpacker/bad_zip/bad_zip.sh

Issue 10870116: Adding binary test files in advance of CL landing, so tryjobs can run (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed copyright notices Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/unpacker/bad_zip/bad_zip.sh
diff --git a/chrome/test/data/extensions/unpacker/bad_zip/bad_zip.sh b/chrome/test/data/extensions/unpacker/bad_zip/bad_zip.sh
new file mode 100755
index 0000000000000000000000000000000000000000..bb147f28b0878b4fbb5e6d708cbc83bc1a86056c
--- /dev/null
+++ b/chrome/test/data/extensions/unpacker/bad_zip/bad_zip.sh
@@ -0,0 +1,41 @@
+#!/bin/bash -e
+
+## Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Purpose: Create a corrupt (invalid ZIP) version of a Chromium crx.
+if test $# -ne 2; then
+ echo "Usage: bad_zip.sh <extension dir> <pem path>"
+ exit 1
+fi
+dir=$1
+key=$2
+name=$(basename "$dir")
+crx="$name.crx"
+pub="$name.pub"
+sig="$name.sig"
+zip="$name.zip"
+trap 'rm -f "$pub" "$sig" "$zip"' EXIT
+# zip up the crx dir
+cwd=$(pwd -P)
+(cd "$dir" && zip -qr -9 -X "$cwd/$zip" .)
+# truncate the zip to 8K so it's invalid
+dd if=$zip of=$zip+ bs=1024 count=8 2>/dev/null && mv $zip+ $zip
+# signature
+openssl sha1 -sha1 -binary -sign "$key" < "$zip" > "$sig"
+# public key
+openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null
+byte_swap () {
+ # Take "abcdefgh" and return it as "ghefcdab"
+ echo "${1:6:2}${1:4:2}${1:2:2}${1:0:2}"
+}
+crmagic_hex="4372 3234" # Cr24
+version_hex="0200 0000" # 2
+pub_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$pub" | awk '{print $5}')))
+sig_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$sig" | awk '{print $5}')))
+(
+ echo "$crmagic_hex $version_hex $pub_len_hex $sig_len_hex" | xxd -r -p
+ cat "$pub" "$sig" "$zip"
+) > "$crx"
+echo "Wrote $crx with invalid ZIP"
« no previous file with comments | « chrome/test/data/extensions/unpacker/bad_zip/bad_zip.pem ('k') | chrome/test/data/extensions/unpacker/bad_zip/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698