nserver

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit 43ea5e861be8ce4914c53cc78a7c4e6c9deec28e
parent 30f4a95b0b100dd72e051d01e738126b4e0a3c3d
Author: rsiddharth <s@ricketyspace.net>
Date:   Thu, 21 Nov 2019 21:14:39 -0500

nserve: Update nserve.

* nserver/src/nserve.c (nserve): Add command size check.

Diffstat:
nserver/src/nserve.c | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/nserver/src/nserve.c b/nserver/src/nserve.c @@ -54,8 +54,16 @@ void nserve(int sock) ssize_t bytes = slurpsock(buf, buf_sz, sock); check(bytes >= 0, "nserve: slurpsock failed"); + int rc = check_cmd_size(buf, sock); + check(rc != -1, "command size check failed"); + + // Quit immediately if cmd size is too large. + if (rc == 1) { + goto error; + } + // Write response to socket. - int rc = barfsock(buf, bytes, sock); + rc = barfsock(buf, bytes, sock); check(rc != -1, "nserve: echo failed"); // Close socket.