luoluoyuyu commented on code in PR #17741:
URL: https://github.com/apache/iotdb/pull/17741#discussion_r3309325964


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java:
##########
@@ -337,6 +350,23 @@ public TSStatus transportFile(final TSyncTransportMetaInfo 
metaInfo, final ByteB
     return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS, "");
   }
 
+  private static File resolveFileInFileDataDir(final String fileDir, final 
String fileName)
+      throws IOException {
+    if (StringUtils.isEmpty(fileName)) {
+      throw new 
IOException(String.format(PipeMessages.ILLEGAL_FILENAME_PATH_TRAVERSAL, 
fileName));
+    }
+
+    final String illegalError = FileUtils.getIllegalError4Directory(fileName);
+    if (Objects.nonNull(illegalError)) {
+      throw new IOException(
+          String.format(PipeMessages.ILLEGAL_FILENAME_PATH_TRAVERSAL, fileName)
+              + ", "
+              + illegalError);
+    }
+
+    return PipeReceiverFilePathUtils.resolveFilePath(Paths.get(fileDir), 
fileName).toFile();

Review Comment:
   👍 使用 `PipeReceiverFilePathUtils.resolveFilePath` 替代 `new File(fileDir, 
fileName)` 是正确的修复。
   
   **建议补 IT**(可 follow-up):
   - `transportFile` 传入 `../../../etc/passwd` 类 fileName → 期望 `SYNC_FILE_ERROR`
   - 正常 tsFile 名仍可续传
   
   同时确认 `getIllegalError4Directory` 对 `foo/bar`(子路径)与 `..` 的覆盖与 thrift 协议文档一致。



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to