Skip to content

Commit 1f207ec

Browse files
nddipiazzaCopilot
andcommitted
TIKA-4721: Validate port range from READY signal
Throw IOException if the server reports a port outside [1, 65535] to catch any malformed or out-of-range values early. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c6bb44a commit 1f207ec

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

tika-pipes/tika-pipes-core/src/main/java/org/apache/tika/pipes/core/SharedServerManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,11 @@ private int waitForServerReady() throws IOException, ServerInitializationExcepti
334334
String line = reader.readLine();
335335
if (line != null && line.startsWith("READY:")) {
336336
String portStr = line.substring("READY:".length()).trim();
337-
return Integer.parseInt(portStr);
337+
int port = Integer.parseInt(portStr);
338+
if (port <= 0 || port > 65535) {
339+
throw new IOException("Server reported invalid port: " + port);
340+
}
341+
return port;
338342
}
339343
} else {
340344
// No data available, sleep briefly

0 commit comments

Comments
 (0)