{
int len = 10+blen;
int rc;
- unsigned char *request = malloc(len);
+ int i,j;
+ unsigned char *request;
+
+ for (i = 0; i < blen; i++) {
+ if (buf[i] == 0x0a)
+ len++;
+ }
+
+ request = malloc(len);
memset(request, 0, len);
request[0] = SOL_DATA_TO_HOST;
- request[8] = blen & 0xff;
- request[9] = blen >> 8;
- memcpy(request + 10, buf, blen);
+ 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];
+ }
rc = redir_write(r, request, len);
free(request);
return rc;