Skip to content

Wrong processing of authentication data in the server mode #95

@dzmipt

Description

@dzmipt

The code assumes that authentication data (user:password) are less of 100 bytes and would be read by a single InputStream.read.

Here is an echo-like Sample:

import com.kx.c;

import java.io.IOException;
import java.net.ServerSocket;
import java.util.Arrays;

public class Test {
    public static void main(String[] args) throws IOException, c.KException {
        ServerSocket ss = new ServerSocket(1111);
        c conn = new c(ss, new c.IAuthenticate() {
            @Override
            public boolean authenticate(String s) {
                System.out.println("auth: " + s + "; len: " + s.length());
                return true;
            }
        });

        while(true) {
            Object[] objs = conn.readMsg();
            if (((byte)objs[0]) == 0) {
                System.out.println("async");
            } else {
                System.out.println("sync");
                conn.kr(objs[1]);
            }
        }
    }
}

And now how we can lock (both Java and q client side):

q)(`$":localhost:1111:",200#"u") "aaa"

Here is what we got in Java before the hang:

auth: uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu; len: 97

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions