From 0ddcc0c9d7180d78badb07518058d198bcfa4cb9 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Mon, 12 May 2008 16:08:39 +0200 Subject: [PATCH] revert enter expansion and simply replace 0x0a with 0x0d --- redir.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/redir.c b/redir.c index 9c72bf7..aed176d 100644 --- a/redir.c +++ b/redir.c @@ -236,27 +236,24 @@ int redir_sol_send(struct redir *r, unsigned char *buf, int blen) { int len = 10+blen; int rc; - int i,j; + int i; unsigned char *request; for (i = 0; i < blen; i++) { if (buf[i] == 0x0a) - len++; + buf[i] = 0x0d; } request = malloc(len); + if (!request) { + return -1; + } memset(request, 0, len); request[0] = SOL_DATA_TO_HOST; - request[8] = (len-10) & 0xff; - request[9] = (len-10) >> 8; - for (i=0, j=0; i < blen; i++,j++) { - if (buf[i] == 0x0a) { - request[j + 10] = 0x0d; - j++; - } - request[j + 10] = buf[i]; - } + request[8] = blen & 0xff; + request[9] = blen >> 8; + memcpy(request + 10, buf, blen); rc = redir_write(r, request, len); free(request); return rc; -- 2.39.5