const gchar *h;
static gchar buf[BUFSIZ];
gchar *t;
- guint len, inlen;
+ guint len, inlen, added = 0;
gboolean got_sp, finished = FALSE;
if (size > sizeof (buf)) {
if (*h == '\n' && h != *start && *(h - 1) != '\r') {
*t++ = '\r';
inlen--;
+ added ++;
if (inlen == 0) {
break;
}
else if (*h == '\r' && *(h + 1) != '\n') {
*t++ = *h++;
*t++ = '\n';
+ added ++;
if (inlen > 1) {
inlen -= 2;
}
if (*remain > 0) {
size_t cklen = MIN(t - buf, *remain);
g_checksum_update (ck, buf, cklen);
- *remain = *remain - cklen;
+ *remain = *remain - (cklen - added);
#if 0
msg_debug ("update signature with buffer (%ud size, %ud remain): %*s",
cklen, *remain, cklen, buf);
const gchar *h;
static gchar buf[BUFSIZ];
gchar *t;
- guint len, inlen;
+ guint len, inlen, added = 0;
gboolean finished = FALSE;
if (size > sizeof (buf)) {
/* Replace a single \n or \r with \r\n */
if (*h == '\n' && *(h - 1) != '\r') {
*t++ = '\r';
+ added ++;
inlen--;
}
else if (*h == '\r' && *(h + 1) != '\n') {
*t++ = *h++;
+ added ++;
*t++ = '\n';
if (inlen > 1) {
inlen -= 2;
if (*remain > 0) {
size_t cklen = MIN(t - buf, *remain);
g_checksum_update (ck, buf, cklen);
- *remain = *remain - cklen;
+ *remain = *remain - (cklen - added);
}
return !finished;