commit - 2cd46d73b60506fa8da4a5f9dba082d709502b53
commit + cd6f9b0334b79f24cf4c6a3a098bc3aa11e6f477
blob - 6556177889fc16102f015eda4e368e3d68b9451f
blob + cd8936cf464c880415aeeae99c4c3de9758604e1
--- Makefile
+++ Makefile
+LOCALBASE?= /usr/local/
PROG= filter-dkimsign
MAN= filter-dkimsign.8
BINDIR= ${LOCALBASE}/libexec/smtpd/
blob - 067c71b06ad1ea0df8fc7b69e999e6b2b39067ab
blob + 890474469a6d8b245f380cfc663aaa34664b7ef0
--- main.c
+++ main.c
fieldname = 1;
for (r = w = 0; line[r] != '\0'; r++) {
if (line[r] == ':' && fieldname) {
- if (line[w - 1] == ' ')
+ if (w > 0 && line[w - 1] == ' ')
line[w - 1] = ':';
else
line[w++] = ':';
}
if (line[r] == ' ' || line[r] == '\t' ||
line[r] == '\r' || line[r] == '\n') {
- if (r != 0 && line[w - 1] == ' ')
+ if (r != 0 && w != 0 && line[w - 1] == ' ')
continue;
else
line[w++] = ' ';
} else
line[w++] = line[r];
}
- linelen = line[w - 1] == ' ' ? w - 1 : w;
+ linelen = (w != 0 && line[w - 1] == ' ') ? w - 1 : w;
line[linelen] = '\0';
} else
linelen = strlen(line);
} else
line[w++] = line[r];
}
- linelen = line[w - 1] == ' ' ? w - 1 : w;
+ linelen = (w != 0 && line[w - 1] == ' ') ? w - 1 : w;
line[linelen] = '\0';
} else
linelen = strlen(line);