-
-/*
- * dropsbr.c -- create/read/manipulate mail drops
+/* dropsbr.c -- create/read/manipulate mail drops
*
* This code is Copyright (c) 2002, by the authors of nmh. See the
* COPYRIGHT file in the root directory of the nmh distribution for
/* attempt to open and lock file */
for (count = 4; count > 0; count--) {
int failed_to_lock = 0;
- if ((fd = lkopenspool (file, O_RDWR | O_CREAT |
- O_NONBLOCK, mode, &failed_to_lock)) == NOTOK) {
- if (failed_to_lock) {
- j = errno;
- sleep (5);
- continue;
- } else {
- return NOTOK;
- }
- }
- /* good file descriptor */
- break;
+ if ((fd = lkopenspool (file, O_RDWR | O_CREAT | O_NONBLOCK,
+ mode, &failed_to_lock)) != NOTOK)
+ break;
+
+ if (!failed_to_lock)
+ return NOTOK;
+
+ j = errno;
+ sleep (5);
}
errno = j;
int i, j, size;
off_t start, stop;
long pos;
- char *cp, buffer[BUFSIZ];
+ char *cp, buffer[BUFSIZ + 1]; /* Space for NUL. */
FILE *fp;
pos = (long) lseek (md, (off_t) 0, SEEK_CUR);
size++;
}
- while ((i = read (fd, buffer, sizeof(buffer))) > 0) {
- /* valgrind noticed that stringdex depends on null
- termination. */
- buffer[i] = '\0';
+ while ((i = read (fd, buffer, sizeof buffer - 1)) > 0) {
+ buffer[i] = '\0'; /* Terminate for stringdex(). */
for ( ; (j = stringdex (mmdlm1, buffer)) >= 0; buffer[j]++)
continue;
* back to "From ".
*/
if (has_prefix(buffer, "Return-Path:")) {
- char tmpbuffer[BUFSIZ];
+ char tmpbuffer[sizeof buffer];
char *tp, *ep, *fp;
strncpy(tmpbuffer, buffer, sizeof(tmpbuffer));
* Change the "X-Envelope-From:" field
* (if first line) back to "From ".
*/
- char tmpbuffer[BUFSIZ];
+ char tmpbuffer[sizeof buffer];
char *ep;
strncpy(tmpbuffer, buffer, sizeof(tmpbuffer));
* If there is already a "From " line,
* then leave it alone. Else we add one.
*/
- char tmpbuffer[BUFSIZ];
+ char tmpbuffer[sizeof buffer];
char *tp, *ep;
strncpy(tmpbuffer, buffer, sizeof(tmpbuffer));
if (read (fd, (char *) &tmpd, sizeof(*dp)) != sizeof(*dp)) {
#ifdef notdef
- admonish (NULL, "%s: missing or partial index", file);
+ inform("%s: missing or partial index, continuing...", file);
#endif /* notdef */
return NOTOK;
}
if (dp->d_size != DRVRSN) {
if (noisy)
- admonish (NULL, "%s: version mismatch (%d != %d)", file,
+ inform("%s: version mismatch (%d != %d), continuing...", file,
dp->d_size, DRVRSN);
return NOTOK;
}
if (dp->d_stop != pos) {
if (noisy && pos != (long) 0)
- admonish (NULL,
- "%s: pointer mismatch or incomplete index (%ld!=%ld)",
- file, dp->d_stop, (long) pos);
+ inform("%s: pointer mismatch or incomplete index (%ld!=%ld), "
+ "continuing...", file, dp->d_stop, (long) pos);
return NOTOK;
}
if ((long) ((dp->d_id + 1) * sizeof(*dp)) != (long) lseek (fd, (off_t) 0, SEEK_END)) {
if (noisy)
- admonish (NULL, "%s: corrupt index(1)", file);
+ inform("%s: corrupt index(1), continuing...", file);
return NOTOK;
}
|| (ntohl(dl->d_stop) != dp->d_stop
&& ntohl(dl->d_stop) + count != dp->d_stop)) {
if (noisy)
- admonish (NULL, "%s: corrupt index(2)", file);
+ inform("%s: corrupt index(2), continuing...", file);
return NOTOK;
}