Skip to content

Commit 8c9ce41

Browse files
committed
Deny disallowed local file loading
1 parent 19d33f5 commit 8c9ce41

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/main/java/io/asyncer/r2dbc/mysql/internal/util/ReadCompletionHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
import java.util.concurrent.atomic.AtomicReference;
2929

3030
/**
31-
* TODO: add javadoc here
31+
* An implementation of {@link CompletionHandler} that reads data from an asynchronous file channel and emits
32+
* file data or I/O exception to a {@link FluxSink}.
3233
*/
3334
final class ReadCompletionHandler implements CompletionHandler<Integer, ByteBuf> {
3435

src/main/java/io/asyncer/r2dbc/mysql/message/client/LocalInfileResponse.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ public Flux<ByteBuf> encode(ByteBufAllocator allocator, ConnectionContext contex
6363
Path safePath = context.getLocalInfilePath();
6464
Path file = Paths.get(this.path);
6565

66-
if (safePath == null || file.startsWith(safePath)) {
66+
if (safePath == null) {
67+
String message = "Allowed local file path not set, but attempted to load '" + file +
68+
'\'';
69+
sink.error(new R2dbcPermissionDeniedException(message));
70+
} else if (file.startsWith(safePath)) {
6771
sink.success(file);
6872
} else {
6973
String message = String.format("The file '%s' is not under the safe path '%s'",

0 commit comments

Comments
 (0)