buf.reset();
switch (encode) {
case ENC_7BIT:
- for (;;) {
- int c = getc(fd);
- if (c == EOF)
- return (buf.getLength() > 0);
- c &= 0xff;
- if (c == '\n') { // check for boundary marker
- lineno++;
- u_int cc = buf.getLength();
- if (cc >= blen && buf[0] == '-') {
- if (cc == blen && strneq(buf, boundary, blen))
- return (false);
- if (cc == blen+2 && strneq(buf, boundary, blen+2)) {
- lastPart = true;
- return (false);
- }
- }
- buf.put('\n');
- return (true);
- }
- buf.put(c);
- }
- /*NOTREACHED*/
+ for (;;) {
+ int c = getc(fd);
+ if (c == EOF) {
+ return (buf.getLength() > 0);
+ }
+ c &= 0xff;
+ if (c == '\n') { // check for boundary marker
+ lineno++;
+ u_int cc = buf.getLength();
+ if (cc >= blen && buf[0] == '-') {
+ if (cc == blen && strneq(buf, boundary, blen)) {
+ return (false);
+ }
+ if (cc == blen+2 && strneq(buf, boundary, blen+2)) {
+ lastPart = true;
+ return (false);
+ }
+ }
+ buf.put('\n');
+ return (true);
+ }
+ buf.put(c);
+ }
+ /*NOTREACHED*/
case ENC_8BIT:
case ENC_BINARY:
- for (;;) {
- int c = getc(fd);
- if (c == EOF)
- return (buf.getLength() > 0);
- c &= 0xff;
- if (c == '\n') { // check for boundary marker
- lineno++;
- u_int cc = buf.getLength();
- if (cc >= blen && buf[0] == '-') {
- if (cc == blen && strneq(buf, boundary, blen))
- return (false);
- if (cc == blen+2 && strneq(buf, boundary, blen+2)) {
- lastPart = true;
- return (false);
- }
- }
- buf.put('\n');
- return (true);
- }
- buf.put(c);
- }
- /*NOTREACHED*/
+ for (;;) {
+ int c = getc(fd);
+ if (c == EOF) {
+ return (buf.getLength() > 0);
+ }
+ c &= 0xff;
+ if (c == '\n') { // check for boundary marker
+ lineno++;
+ u_int cc = buf.getLength();
+ if (cc >= blen && buf[0] == '-') {
+ if (cc == blen && strneq(buf, boundary, blen)) {
+ return (false);
+ }
+ if (cc == blen+2 && strneq(buf, boundary, blen+2)) {
+ lastPart = true;
+ return (false);
+ }
+ }
+ buf.put('\n');
+ return (true);
+ }
+ buf.put(c);
+ }
+ /*NOTREACHED*/
case ENC_QPRINT: return getQuotedPrintableLine(fd, buf);
case ENC_BASE64: return getBase64Line(fd, buf);
case ENC_UUENCODE: return getUUDecodeLine(fd, buf);
char tmpl[128];
sprintf(tmpl, "%s/faxmailXXXXXX", _PATH_TMP);
int fd = Sys::mkstemp(tmpl);
- if (fd < 0)
- fxFatal("Cannot create temp file %s", (const char*) tmpl);
+ if (fd < 0) {
+ fxFatal("Cannot create temp file %s", (const char*) tmpl);
+ }
+ // security add for glibc < 2.0.7
+ if (fchmod(fd, 600) == -1) {
+ fxFatal("%s: %s", (const char*) tmpl, strerror(errno));
+ }
tmps.append(tmpl);
client->addFile(tmpl);
beginFormatting(fdopen(fd, "w"));
static void
tiffErrorHandler(const char* module, const char* fmt0, va_list ap)
{
- char fmt[128];
- if (module != NULL)
- sprintf(fmt, "%s: Warning, %s.", module, fmt0);
- else
- sprintf(fmt, "Warning, %s.", fmt0);
+ char fmt[128] = {0};
+ if (module != NULL) {
+ snprintf(fmt, sizeof(fmt) -1, "%s: Warning, %s.", module, fmt0);
+ } else {
+ snprintf(fmt, sizeof(fmt) - 1, "Warning, %s.", fmt0);
+ }
vlogError(fmt, ap);
}
static void
tiffWarningHandler(const char* module, const char* fmt0, va_list ap)
{
- char fmt[128];
- if (module != NULL)
- sprintf(fmt, "%s: Warning, %s.", module, fmt0);
- else
- sprintf(fmt, "Warning, %s.", fmt0);
+ char fmt[128] = {0};
+ if (module != NULL) {
+ snprintf(fmt, sizeof(fmt) -1, "%s: Warning, %s.", module, fmt0);
+ } else {
+ snprintf(fmt, sizeof(fmt) -1, "Warning, %s.", fmt0);
+ }
vlogWarning(fmt, ap);
}
TIFFSetField(tif, TIFFTAG_PAGENUMBER, pn, npages);
TIFFSetField(tif, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_CLEAN);
{ char buf[1024];
- sprintf(buf, "Ditherered B&W version of %s", input);
+ snprintf(buf, sizeof(buf) - 1, "Ditherered B&W version of %s", input);
TIFFSetField(tif, TIFFTAG_IMAGEDESCRIPTION, buf);
}
TIFFSetField(tif, TIFFTAG_SOFTWARE, "sgi2fax");