diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2007-09-18 00:38:59 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2007-09-18 00:38:59 +0000 |
commit | 431db9b83f301f2bf82d88ed2b75bb958f457964 (patch) | |
tree | 90468d2d1860e295400a78ac45503e8e9ed1ed49 /usr.bin/sendbug/sendbug.c | |
parent | 7a3efd9bfaf8248fb1e9f131aec3870b64089ded (diff) |
Don't treat lines in angle brackets <...> as comments in dmesg.
Discovered and tested by deanna.
Diffstat (limited to 'usr.bin/sendbug/sendbug.c')
-rw-r--r-- | usr.bin/sendbug/sendbug.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/usr.bin/sendbug/sendbug.c b/usr.bin/sendbug/sendbug.c index 81811e639b3..8492a5853d0 100644 --- a/usr.bin/sendbug/sendbug.c +++ b/usr.bin/sendbug/sendbug.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sendbug.c,v 1.50 2007/07/31 03:44:21 ray Exp $ */ +/* $OpenBSD: sendbug.c,v 1.51 2007/09/18 00:38:58 ray Exp $ */ /* * Written by Ray Lai <ray@cyth.net>. @@ -27,6 +27,7 @@ #include "atomicio.h" #define _PATH_DMESG "/var/run/dmesg.boot" +#define DMESG_START "OpenBSD " int checkfile(const char *); void dmesg(FILE *); @@ -191,14 +192,14 @@ dmesg(FILE *fp) "<dmesg is attached.>\n" "<Feel free to delete or use the -D flag if it contains " "sensitive information.>\n", fp); - /* Find last line starting with "OpenBSD". */ + /* Find last dmesg. */ for (;;) { off_t o; o = ftello(dfp); if (fgets(buf, sizeof(buf), dfp) == NULL) break; - if (!strncmp("OpenBSD ", buf, sizeof("OpenBSD ") - 1)) + if (!strncmp(DMESG_START, buf, sizeof(DMESG_START) - 1)) offset = o; } if (offset != -1) { @@ -414,10 +415,10 @@ init(void) int send_file(const char *file, int dst) { - int blank = 0; size_t len; char *buf; FILE *fp; + int blank = 0, dmesg_line = 0; if ((fp = fopen(file, "r")) == NULL) return (-1); @@ -426,14 +427,21 @@ send_file(const char *file, int dst) if (len >= sizeof("SENDBUG") - 1 && memcmp(buf, "SENDBUG", sizeof("SENDBUG") - 1) == 0) continue; - if (len == 1 && buf[0] == '\n') + /* Are we done with the headers? */ + if (!blank && len == 1 && buf[0] == '\n') blank = 1; - /* Skip comments, but only if we encountered a blank line. */ + /* Have we reached the dmesg? */ + if (blank && !dmesg_line && + len >= sizeof(DMESG_START) - 1 && + memcmp(buf, DMESG_START, sizeof(DMESG_START) - 1) == 0) + dmesg_line = 1; + /* Skip comments between headers and dmesg. */ while (len) { char *sp = NULL, *ep = NULL; size_t copylen; - if (blank && (sp = memchr(buf, '<', len)) != NULL) + if (blank && !dmesg_line && + (sp = memchr(buf, '<', len)) != NULL) ep = memchr(sp, '>', len - (sp - buf + 1)); /* Length of string before comment. */ if (ep) |