2 * Copyright (c) 1998-2003, 2010, 2015 Proofpoint, Inc. and its suppliers.
4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved.
5 * Copyright (c) 1988, 1993
6 * The Regents of the University of California. All rights reserved.
8 * By using this file, you agree to the terms and conditions set
9 * forth in the LICENSE file which can be found at the top level of
10 * the sendmail distribution.
16 SM_RCSID("@(#)$Id: err.c,v 8.206 2013-11-22 20:51:55 ca Exp $")
20 # include <ldap.h> /* for LDAP error codes */
23 static void putoutmsg __P((char *, bool, bool));
24 static void puterrmsg __P((char *));
25 static char *fmtmsg __P((char *, const char *, const char *, const char *,
26 int, const char *, va_list));
29 ** FATAL_ERROR -- handle a fatal exception
31 ** This function is installed as the default exception handler
32 ** in the main sendmail process, and in all child processes
33 ** that we create. Its job is to handle exceptions that are not
34 ** handled at a lower level.
36 ** The theory is that unhandled exceptions will be 'fatal' class
37 ** exceptions (with an "F:" prefix), such as the out-of-memory
38 ** exception "F:sm.heap". As such, they are handled by exiting
39 ** the process in exactly the same way that xalloc() in Sendmail 8.10
40 ** exits the process when it fails due to lack of memory:
41 ** we call syserr with a message beginning with "!".
44 ** exc -- exception which is terminating this process
58 ** This function may be called when the heap is exhausted.
59 ** The following code writes the message for 'exc' into our
60 ** static buffer without allocating memory or raising exceptions.
63 sm_strio_init(&f, buf, sizeof(buf));
64 sm_exc_write(exc, &f);
65 (void) sm_io_flush(&f, SM_TIME_DEFAULT);
68 ** Terminate the process after logging an error and cleaning up.
70 ** - syserr decides what class of error this is by looking at errno.
71 ** That's no good; we should look at the exc structure.
72 ** - The cleanup code should be moved out of syserr
73 ** and into individual exception handlers
74 ** that are part of the module they clean up after.
82 ** SYSERR -- Print error message.
84 ** Prints an error message via sm_io_printf to the diagnostic output.
86 ** If the first character of the syserr message is `!' it will
87 ** log this as an ALERT message and exit immediately. This can
88 ** leave queue files in an indeterminate state, so it should not
91 ** If the first character of the syserr message is '!' or '@'
92 ** then syserr knows that the process is about to be terminated,
93 ** so the SMTP reply code defaults to 421. Otherwise, the
94 ** reply code defaults to 451 or 554, depending on errno.
97 ** fmt -- the format string. An optional '!', '@', or '+',
98 ** followed by an optional three-digit SMTP
99 ** reply code, followed by message text.
100 ** (others) -- parameters
104 ** Raises E:mta.quickabort if QuickAbort is set.
107 ** increments Errors.
111 char MsgBuf[BUFSIZ*2]; /* text of most recent message */
112 static char HeldMessageBuf[sizeof(MsgBuf)]; /* for held messages */
114 #if NAMED_BIND && !defined(NO_DATA)
115 # define NO_DATA NO_ADDRESS
121 syserr(const char *fmt, ...)
123 syserr(fmt, va_alist)
126 #endif /* __STDC__ */
129 int save_errno = errno;
130 bool panic, exiting, keep;
138 panic = exiting = keep = false;
143 panic = exiting = true;
157 /* format and output the error message */
161 ** Since we are terminating the process,
162 ** we are aborting the entire SMTP session,
163 ** rather than just the current transaction.
169 else if (save_errno == 0)
179 SM_VA_START(ap, fmt);
180 errtxt = fmtmsg(MsgBuf, (char *) NULL, p, enhsc, save_errno, fmt, ap);
184 /* save this message for mailq printing */
185 if (!panic && CurEnv != NULL && (!keep || CurEnv->e_message == NULL))
187 char *nmsg = sm_rpool_strdup_x(CurEnv->e_rpool, errtxt);
189 if (CurEnv->e_rpool == NULL && CurEnv->e_message != NULL)
190 sm_free(CurEnv->e_message);
191 CurEnv->e_message = nmsg;
194 /* determine exit status if not already set */
195 if (ExitStat == EX_OK)
198 ExitStat = EX_SOFTWARE;
202 sm_dprintf("syserr: ExitStat = %d\n", ExitStat);
205 pw = sm_getpwuid(RealUid);
211 (void) sm_snprintf(ubuf, sizeof(ubuf), "UID%d", (int) RealUid);
215 sm_syslog(panic ? LOG_ALERT : LOG_CRIT,
216 CurEnv == NULL ? NOQID : CurEnv->e_id,
217 "SYSERR(%s): %.900s",
241 mci_dump_all(smioout, true);
256 sm_exc_raisenew_x(&EtypeQuickAbort, 2);
260 ** USRERR -- Signal user error.
262 ** This is much like syserr except it is for user errors.
265 ** fmt -- the format string. If it does not begin with
266 ** a three-digit SMTP reply code, 550 is assumed.
267 ** (others) -- sm_io_printf strings
271 ** Raises E:mta.quickabort if QuickAbort is set.
274 ** increments Errors.
280 usrerr(const char *fmt, ...)
282 usrerr(fmt, va_alist)
285 #endif /* __STDC__ */
291 if (fmt[0] == '5' || fmt[0] == '6')
293 else if (fmt[0] == '4' || fmt[0] == '8')
295 else if (fmt[0] == '2')
299 SM_VA_START(ap, fmt);
300 errtxt = fmtmsg(MsgBuf, CurEnv->e_to, "550", enhsc, 0, fmt, ap);
306 /* save this message for mailq printing */
311 if (CurEnv->e_message != NULL)
318 if (CurEnv->e_rpool == NULL && CurEnv->e_message != NULL)
319 sm_free(CurEnv->e_message);
320 if (MsgBuf[0] == '6')
324 (void) sm_snprintf(buf, sizeof(buf),
325 "Postmaster warning: %.*s",
326 (int) sizeof(buf) - 22, errtxt);
328 sm_rpool_strdup_x(CurEnv->e_rpool, buf);
333 sm_rpool_strdup_x(CurEnv->e_rpool, errtxt);
339 if (LogLevel > 3 && LogUsrErrs)
340 sm_syslog(LOG_NOTICE, CurEnv->e_id, "%.900s", errtxt);
342 sm_exc_raisenew_x(&EtypeQuickAbort, 1);
346 ** USRERRENH -- Signal user error.
348 ** Same as usrerr but with enhanced status code.
351 ** enhsc -- the enhanced status code.
352 ** fmt -- the format string. If it does not begin with
353 ** a three-digit SMTP reply code, 550 is assumed.
354 ** (others) -- sm_io_printf strings
358 ** Raises E:mta.quickabort if QuickAbort is set.
361 ** increments Errors.
367 usrerrenh(char *enhsc, const char *fmt, ...)
369 usrerrenh(enhsc, fmt, va_alist)
373 #endif /* __STDC__ */
378 if (enhsc == NULL || *enhsc == '\0')
380 if (fmt[0] == '5' || fmt[0] == '6')
382 else if (fmt[0] == '4' || fmt[0] == '8')
384 else if (fmt[0] == '2')
387 SM_VA_START(ap, fmt);
388 errtxt = fmtmsg(MsgBuf, CurEnv->e_to, "550", enhsc, 0, fmt, ap);
394 /* save this message for mailq printing */
399 if (CurEnv->e_message != NULL)
406 if (CurEnv->e_rpool == NULL && CurEnv->e_message != NULL)
407 sm_free(CurEnv->e_message);
408 if (MsgBuf[0] == '6')
412 (void) sm_snprintf(buf, sizeof(buf),
413 "Postmaster warning: %.*s",
414 (int) sizeof(buf) - 22, errtxt);
416 sm_rpool_strdup_x(CurEnv->e_rpool, buf);
421 sm_rpool_strdup_x(CurEnv->e_rpool, errtxt);
427 if (LogLevel > 3 && LogUsrErrs)
428 sm_syslog(LOG_NOTICE, CurEnv->e_id, "%.900s", errtxt);
430 sm_exc_raisenew_x(&EtypeQuickAbort, 1);
434 ** MESSAGE -- print message (not necessarily an error)
437 ** msg -- the message (sm_io_printf fmt) -- it can begin with
438 ** an SMTP reply code. If not, 050 is assumed.
439 ** (others) -- sm_io_printf arguments
448 message(const char *msg, ...)
450 message(msg, va_alist)
453 #endif /* __STDC__ */
459 SM_VA_START(ap, msg);
460 errtxt = fmtmsg(MsgBuf, CurEnv->e_to, "050", (char *) NULL, 0, msg, ap);
462 putoutmsg(MsgBuf, false, false);
464 /* save this message for mailq printing */
469 if (CurEnv->e_message != NULL)
474 if (CurEnv->e_rpool == NULL && CurEnv->e_message != NULL)
475 sm_free(CurEnv->e_message);
476 CurEnv->e_message = sm_rpool_strdup_x(CurEnv->e_rpool, errtxt);
483 ** EMESSAGE -- print message (not necessarily an error)
484 ** (same as message() but requires reply code and enhanced status code)
487 ** replycode -- SMTP reply code.
488 ** enhsc -- enhanced status code.
489 ** msg -- the message (sm_io_printf fmt) -- it can begin with
490 ** an SMTP reply code. If not, 050 is assumed.
491 ** (others) -- sm_io_printf arguments
500 emessage(const char *replycode, const char *enhsc, const char *msg, ...)
501 # else /* __STDC__ */
502 emessage(replycode, enhsc, msg, va_alist)
503 const char *replycode;
507 # endif /* __STDC__ */
513 SM_VA_START(ap, msg);
514 errtxt = fmtmsg(MsgBuf, CurEnv->e_to, replycode, enhsc, 0, msg, ap);
516 putoutmsg(MsgBuf, false, false);
518 /* save this message for mailq printing */
523 if (CurEnv->e_message != NULL)
528 if (CurEnv->e_rpool == NULL && CurEnv->e_message != NULL)
529 sm_free(CurEnv->e_message);
530 CurEnv->e_message = sm_rpool_strdup_x(CurEnv->e_rpool, errtxt);
536 ** EXTSC -- check and extract a status codes
539 ** msg -- string with possible enhanced status code.
540 ** delim -- delim for enhanced status code.
541 ** replycode -- pointer to storage for SMTP reply code;
542 ** must be != NULL and have space for at least
544 ** enhsc -- pointer to storage for enhanced status code;
545 ** must be != NULL and have space for at least
546 ** 10 characters ([245].[0-9]{1,3}.[0-9]{1,3})
549 ** -1 -- no SMTP reply code.
550 ** >=3 -- offset of error text in msg.
551 ** (<=4 -- no enhanced status code)
555 extsc(msg, delim, replycode, enhsc)
563 SM_REQUIRE(replycode != NULL);
564 SM_REQUIRE(enhsc != NULL);
569 if (!ISSMTPREPLY(msg))
571 sm_strlcpy(replycode, msg, 4);
575 if (isenhsc(msg + 4, delim))
576 offset = extenhsc(msg + 4, delim, enhsc) + 4;
579 #endif /* _FFR_PROXY */
582 ** NMESSAGE -- print message (not necessarily an error)
584 ** Just like "message" except it never puts the to... tag on.
587 ** msg -- the message (sm_io_printf fmt) -- if it begins
588 ** with a three digit SMTP reply code, that is used,
589 ** otherwise 050 is assumed.
590 ** (others) -- sm_io_printf arguments
599 nmessage(const char *msg, ...)
601 nmessage(msg, va_alist)
604 #endif /* __STDC__ */
610 SM_VA_START(ap, msg);
611 errtxt = fmtmsg(MsgBuf, (char *) NULL, "050",
612 (char *) NULL, 0, msg, ap);
614 putoutmsg(MsgBuf, false, false);
616 /* save this message for mailq printing */
621 if (CurEnv->e_message != NULL)
626 if (CurEnv->e_rpool == NULL && CurEnv->e_message != NULL)
627 sm_free(CurEnv->e_message);
628 CurEnv->e_message = sm_rpool_strdup_x(CurEnv->e_rpool, errtxt);
634 ** PUTOUTMSG -- output error message to transcript and channel
637 ** msg -- message to output (in SMTP format).
638 ** holdmsg -- if true, don't output a copy of the message to
639 ** our output channel.
640 ** heldmsg -- if true, this is a previously held message;
641 ** don't log it to the transcript file.
647 ** Outputs msg to the transcript.
648 ** If appropriate, outputs it to the channel.
649 ** Deletes SMTP reply code number as appropriate.
653 putoutmsg(msg, holdmsg, heldmsg)
658 char msgcode = msg[0];
662 /* display for debugging */
664 sm_dprintf("--- %s%s%s\n", msg, holdmsg ? " (hold)" : "",
665 heldmsg ? " (held)" : "");
667 /* map warnings to something SMTP can handle */
670 else if (msgcode == '8')
672 id = (CurEnv != NULL) ? CurEnv->e_id : NULL;
674 /* output to transcript if serious */
675 if (!heldmsg && CurEnv != NULL && CurEnv->e_xfp != NULL &&
676 strchr("45", msg[0]) != NULL)
677 (void) sm_io_fprintf(CurEnv->e_xfp, SM_TIME_DEFAULT, "%s\n",
680 if (LogLevel > 14 && (OpMode == MD_SMTP || OpMode == MD_DAEMON))
681 sm_syslog(LOG_INFO, id,
682 "--- %s%s%s", msg, holdmsg ? " (hold)" : "",
683 heldmsg ? " (held)" : "");
688 /* output to channel if appropriate */
689 if (!Verbose && msg[0] == '0')
693 /* save for possible future display */
695 if (HeldMessageBuf[0] == '5' && msgcode == '4')
697 (void) sm_strlcpy(HeldMessageBuf, msg, sizeof(HeldMessageBuf));
701 (void) sm_io_flush(smioout, SM_TIME_DEFAULT);
703 if (OutChannel == NULL)
706 /* find actual text of error (after SMTP status codes) */
707 if (ISSMTPREPLY(errtxt))
712 l = isenhsc(errtxt, ' ');
714 l = isenhsc(errtxt, '\0');
719 /* if DisConnected, OutChannel now points to the transcript */
721 (OpMode == MD_SMTP || OpMode == MD_DAEMON || OpMode == MD_ARPAFTP))
722 (void) sm_io_fprintf(OutChannel, SM_TIME_DEFAULT, "%s\r\n",
725 (void) sm_io_fprintf(OutChannel, SM_TIME_DEFAULT, "%s\n",
727 if (TrafficLogFile != NULL)
728 (void) sm_io_fprintf(TrafficLogFile, SM_TIME_DEFAULT,
729 "%05d >>> %s\n", (int) CurrentPid,
730 (OpMode == MD_SMTP || OpMode == MD_DAEMON)
733 /* XXX can't flush here for SMTP pipelining */
735 (void) sm_io_flush(OutChannel, SM_TIME_DEFAULT);
736 if (!sm_io_error(OutChannel) || DisConnected)
740 ** Error on output -- if reporting lost channel, just ignore it.
741 ** Also, ignore errors from QUIT response (221 message) -- some
742 ** rude servers don't read result.
745 if (InChannel == NULL || sm_io_eof(InChannel) ||
746 sm_io_error(InChannel) || strncmp(msg, "221", 3) == 0)
749 /* can't call syserr, 'cause we are using MsgBuf */
752 sm_syslog(LOG_CRIT, id,
753 "SYSERR: putoutmsg (%s): error on output channel sending \"%s\": %s",
755 shortenstring(msg, MAXSHORTSTR), sm_errstring(errno));
756 #endif /* !PIPELINING */
760 ** PUTERRMSG -- like putoutmsg, but does special processing for error messages
763 ** msg -- the message to output.
769 ** Sets the fatal error bit in the envelope as appropriate.
776 char msgcode = msg[0];
778 /* output the message as usual */
779 putoutmsg(msg, HoldErrs, false);
781 /* be careful about multiple error messages */
785 /* signal the error */
793 /* notify the postmaster */
794 CurEnv->e_flags |= EF_PM_NOTIFY;
796 else if (msgcode == '5' && bitset(EF_GLOBALERRS, CurEnv->e_flags))
798 /* mark long-term fatal errors */
799 CurEnv->e_flags |= EF_FATALERRS;
804 ** ISENHSC -- check whether a string contains an enhanced status code
807 ** s -- string with possible enhanced status code.
808 ** delim -- delim for enhanced status code.
811 ** 0 -- no enhanced status code.
812 ** >4 -- length of enhanced status code.
824 if (!((*s == '2' || *s == '4' || *s == '5') && s[1] == '.'))
828 while (h < 3 && isascii(s[l + h]) && isdigit(s[l + h]))
830 if (h == 0 || s[l + h] != '.')
834 while (h < 3 && isascii(s[l + h]) && isdigit(s[l + h]))
836 if (h == 0 || s[l + h] != delim)
842 ** EXTENHSC -- check and extract an enhanced status code
845 ** s -- string with possible enhanced status code.
846 ** delim -- delim for enhanced status code.
847 ** e -- pointer to storage for enhanced status code.
848 ** must be != NULL and have space for at least
849 ** 10 characters ([245].[0-9]{1,3}.[0-9]{1,3})
852 ** 0 -- no enhanced status code.
853 ** >4 -- length of enhanced status code.
856 ** fills e with enhanced status code.
860 extenhsc(s, delim, e)
869 if (!((*s == '2' || *s == '4' || *s == '5') && s[1] == '.'))
875 while (h < 3 && isascii(s[l + h]) && isdigit(s[l + h]))
880 if (h == 0 || s[l + h] != '.')
885 while (h < 3 && isascii(s[l + h]) && isdigit(s[l + h]))
890 if (h == 0 || s[l + h] != delim)
897 ** FMTMSG -- format a message into buffer.
900 ** eb -- error buffer to get result -- MUST BE MsgBuf.
901 ** to -- the recipient tag for this message.
902 ** num -- default three digit SMTP reply code.
903 ** enhsc -- enhanced status code.
904 ** en -- the error number to display.
905 ** fmt -- format of string: See NOTE below.
906 ** ap -- arguments for fmt.
909 ** pointer to error text beyond status codes.
912 ** Do NOT use "%s" as fmt if the argument starts with an SMTP
917 fmtmsg(eb, to, num, enhsc, eno, fmt, ap)
928 int spaceleft = sizeof(MsgBuf);
931 /* output the reply code */
941 if (SoftBounce && num[0] == '5')
944 (void) sm_snprintf(eb, spaceleft, "4%2.2s%c", num + 1, del);
947 (void) sm_snprintf(eb, spaceleft, "%3.3s%c", num, del);
951 if ((l = isenhsc(fmt, ' ' )) > 0 && l < spaceleft - 4)
953 /* copy enh.status code including trailing blank */
955 (void) sm_strlcpy(eb, fmt, l + 1);
960 else if ((l = isenhsc(enhsc, '\0')) > 0 && l < spaceleft - 4)
962 /* copy enh.status code */
963 (void) sm_strlcpy(eb, enhsc, l + 1);
969 if (SoftBounce && eb[-l] == '5')
976 /* output the file name and line number */
977 if (FileName != NULL)
979 (void) sm_snprintf(eb, spaceleft, "%s: line %d: ",
980 shortenstring(FileName, 83), LineNumber);
981 eb += (l = strlen(eb));
986 ** output the "to" address only if it is defined and one of the
987 ** following codes is used:
988 ** 050 internal notices, e.g., alias expansion
990 ** 252 Cannot VRFY user, but will accept message and attempt delivery
991 ** 450 Requested mail action not taken: mailbox unavailable
992 ** 550 Requested action not taken: mailbox unavailable
993 ** 553 Requested action not taken: mailbox name not allowed
995 ** Notice: this still isn't "the right thing", this code shouldn't
996 ** (indirectly) depend on CurEnv->e_to.
999 if (to != NULL && to[0] != '\0' &&
1000 (strncmp(num, "050", 3) == 0 ||
1001 strncmp(num, "250", 3) == 0 ||
1002 strncmp(num, "252", 3) == 0 ||
1003 strncmp(num, "450", 3) == 0 ||
1004 strncmp(num, "550", 3) == 0 ||
1005 strncmp(num, "553", 3) == 0))
1007 (void) sm_strlcpyn(eb, spaceleft, 2,
1008 shortenstring(to, MAXSHORTSTR), "... ");
1009 spaceleft -= strlen(eb);
1018 /* output the message */
1019 (void) sm_vsnprintf(eb, spaceleft, fmt, ap);
1020 spaceleft -= strlen(eb);
1028 /* output the error code, if any */
1030 (void) sm_strlcpyn(eb, spaceleft, 2, ": ", sm_errstring(eno));
1036 ** BUFFER_ERRORS -- arrange to buffer future error messages
1048 HeldMessageBuf[0] = '\0';
1053 ** FLUSH_ERRORS -- flush the held error message buffer
1056 ** print -- if set, print the message, otherwise just
1067 if (print && HeldMessageBuf[0] != '\0')
1068 putoutmsg(HeldMessageBuf, false, true);
1069 HeldMessageBuf[0] = '\0';
1073 ** SM_ERRSTRING -- return string description of error code
1076 ** errnum -- the error number to translate
1079 ** A string description of errnum.
1083 sm_errstring(errnum)
1088 static char buf[MAXLINE];
1093 #if !HASSTRERROR && !defined(ERRLIST_PREDEFINED)
1094 extern char *sys_errlist[];
1095 extern int sys_nerr;
1099 ** Handle special network error codes.
1101 ** These are 4.2/4.3bsd specific; they should be in daemon.c.
1111 err = strerror(errnum);
1114 (void) sm_snprintf(errbuf, sizeof(errbuf),
1115 "Error %d", errnum);
1118 (void) sm_strlcpy(bp, err, SPACELEFT(buf, bp));
1119 #else /* HASSTRERROR */
1120 if (errnum >= 0 && errnum < sys_nerr)
1121 (void) sm_strlcpy(bp, sys_errlist[errnum],
1122 SPACELEFT(buf, bp));
1124 (void) sm_snprintf(bp, SPACELEFT(buf, bp),
1125 "Error %d", errnum);
1126 #endif /* HASSTRERROR */
1128 if (CurHostName != NULL)
1130 if (errnum == ETIMEDOUT)
1132 (void) sm_snprintf(bp, SPACELEFT(buf, bp),
1139 (void) sm_snprintf(bp, SPACELEFT(buf, bp),
1140 "Connection reset by ");
1143 (void) sm_strlcpy(bp,
1144 shortenstring(CurHostName, MAXSHORTSTR),
1145 SPACELEFT(buf, bp));
1148 if (SmtpPhase != NULL)
1150 (void) sm_snprintf(bp, SPACELEFT(buf, bp),
1151 " during %s", SmtpPhase);
1156 if (CurHostName == NULL)
1158 (void) sm_snprintf(buf, sizeof(buf), "Host %s is down",
1159 shortenstring(CurHostName, MAXSHORTSTR));
1163 if (CurHostName == NULL)
1165 (void) sm_strlcpyn(buf, sizeof(buf), 2, "Connection refused by ",
1166 shortenstring(CurHostName, MAXSHORTSTR));
1170 case HOST_NOT_FOUND + E_DNSBASE:
1171 dnsmsg = "host not found";
1174 case TRY_AGAIN + E_DNSBASE:
1175 dnsmsg = "host name lookup failure";
1178 case NO_RECOVERY + E_DNSBASE:
1179 dnsmsg = "non-recoverable error";
1182 case NO_DATA + E_DNSBASE:
1183 dnsmsg = "no data known";
1185 #endif /* NAMED_BIND */
1188 /* SunOS gives "Not owner" -- this is the POSIX message */
1189 return "Operation not permitted";
1192 ** Error messages used internally in sendmail.
1195 case E_SM_OPENTIMEOUT:
1196 return "Timeout on file open";
1199 return "Symbolic links not allowed";
1202 return "Hard links not allowed";
1205 return "Regular files only";
1208 return "Executable files not allowed";
1211 return "World writable directory";
1214 return "Group writable directory";
1216 case E_SM_FILECHANGE:
1217 return "File changed after open";
1220 return "World writable file";
1223 return "Group writable file";
1226 return "Group readable file";
1229 return "World readable file";
1235 bp += sm_strlcpy(bp, "Name server: ", sizeof(buf));
1236 if (CurHostName != NULL)
1238 (void) sm_strlcpyn(bp, SPACELEFT(buf, bp), 2,
1239 shortenstring(CurHostName, MAXSHORTSTR), ": ");
1242 (void) sm_strlcpy(bp, dnsmsg, SPACELEFT(buf, bp));
1247 if (errnum >= E_LDAPBASE - E_LDAP_SHIM)
1248 return ldap_err2string(errnum - E_LDAPBASE);
1252 err = strerror(errnum);
1255 (void) sm_snprintf(buf, sizeof(buf), "Error %d", errnum);
1259 #else /* HASSTRERROR */
1260 if (errnum > 0 && errnum < sys_nerr)
1261 return sys_errlist[errnum];
1263 (void) sm_snprintf(buf, sizeof(buf), "Error %d", errnum);
1265 #endif /* HASSTRERROR */