Skip to content

Commit 3e23716

Browse files
authored
Merge pull request #46 from microbit-foundation/install-samples
Fix zip path traversal error and update to v3.0.6 (56)
2 parents 8c61ca0 + 9407953 commit 3e23716

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
-->
1616
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
1717
xmlns:tools="http://schemas.android.com/tools"
18-
android:versionCode="55"
19-
android:versionName="3.0.5">
18+
android:versionCode="56"
19+
android:versionName="3.0.6">
2020

2121
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
2222
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

app/src/main/java/com/samsung/microbit/utils/ProjectsHelper.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,18 @@ public static boolean installSamples( Context context) {
205205
while((ze = zin.getNextEntry()) != null) {
206206
Log.v("MicroBit", "Unzipping " + ze.getName());
207207

208+
File f = projectFile(context, ze.getName());
209+
if (!f.getCanonicalPath().startsWith(projectRoot(context).getCanonicalPath())) {
210+
// Skip file with unexpected directory
211+
continue;
212+
}
213+
208214
if (ze.isDirectory()) {
209-
File f = projectFile( context, ze.getName());
210215
if ( !f.isDirectory()) {
211216
f.mkdirs();
212217
}
213218
} else {
214-
FileOutputStream fout = new FileOutputStream( projectFile( context, ze.getName()));
219+
FileOutputStream fout = new FileOutputStream(f);
215220
BufferedOutputStream bufout = new BufferedOutputStream(fout);
216221
byte[] buffer = new byte[1024];
217222
int read = 0;

0 commit comments

Comments
 (0)