X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Flogfile.c;h=488bdca5c3e05835f2a384d5f9ead82a45ffdfae;hb=f86ca883daf8a5123c8cac43bfd76d514c5b1c82;hp=a1517447e8e5b17f0149343e8f655a9f85707039;hpb=e442edb4d5816c4ad107ad9e71164f845eba70ad;p=debian%2Famanda diff --git a/server-src/logfile.c b/server-src/logfile.c index a151744..488bdca 100644 --- a/server-src/logfile.c +++ b/server-src/logfile.c @@ -52,7 +52,7 @@ char *logtype_str[] = { char *program_str[] = { "UNKNOWN", "planner", "driver", "amreport", "dumper", "chunker", - "taper", "amflush" + "taper", "amflush", "amdump", "amidxtaped", "amfetchdump", "amcheckdump" }; int curlinenum; @@ -118,7 +118,6 @@ printf_arglist_function1(void log_add, logtype_t, typ, char *, format) char linebuf[STR_SIZE]; size_t n; - /* format error message */ if((int)typ <= (int)L_BOGUS || (int)typ > (int)L_MARKER) typ = L_BOGUS; @@ -130,7 +129,8 @@ printf_arglist_function1(void log_add, logtype_t, typ, char *, format) } arglist_start(argp, format); - g_vsnprintf(linebuf, SIZEOF(linebuf)-1, xlated_fmt, argp); + /* use sizeof(linebuf)-2 to save space for a trailing newline */ + g_vsnprintf(linebuf, SIZEOF(linebuf)-2, xlated_fmt, argp); /* -1 to allow for '\n' */ arglist_end(argp); @@ -143,18 +143,19 @@ printf_arglist_function1(void log_add, logtype_t, typ, char *, format) if(multiline == -1) open_log(); - if (fullwrite(logfd, leader, strlen(leader)) < 0) { + if (full_write(logfd, leader, strlen(leader)) < strlen(leader)) { error(_("log file write error: %s"), strerror(errno)); /*NOTREACHED*/ } amfree(leader); + /* add a newline if necessary */ n = strlen(linebuf); if(n == 0 || linebuf[n-1] != '\n') linebuf[n++] = '\n'; linebuf[n] = '\0'; - if (fullwrite(logfd, linebuf, n) < 0) { + if (full_write(logfd, linebuf, n) < n) { error(_("log file write error: %s"), strerror(errno)); /*NOTREACHED*/ }