Merge cherrypicks of [17605899] into rvc-platform-release.

Change-Id: I6ff19cc9220deee8a506e9ed4e64e1e644244537
diff --git a/adb/client/file_sync_client.cpp b/adb/client/file_sync_client.cpp
index e686973..3374812 100644
--- a/adb/client/file_sync_client.cpp
+++ b/adb/client/file_sync_client.cpp
@@ -477,6 +477,17 @@
             if (!ReadFdExactly(fd, buf, len)) return false;
             buf[len] = 0;
 
+            // Address the unlikely scenario wherein a
+            // compromised device/service might be able to
+            // traverse across directories on the host. Let's
+            // shut that door!
+            if (strchr(buf, '/')
+#if defined(_WIN32)
+                || strchr(buf, '\\')
+#endif
+            ) {
+                return false;
+            }
             callback(dent.mode, dent.size, dent.mtime, buf);
         }
     }