ALT Linux repos
Group :: Communications
RPM: mgetty
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: mgetty-1.1.35-strerror.patch
Download
Download
diff --git a/mgetty/logfile.c b/mgetty/logfile.c
index e0951cb..47e543c 100644
--- a/mgetty/logfile.c
+++ b/mgetty/logfile.c
@@ -58,10 +58,10 @@ extern int atexit _PROTO(( void (*)(void) ));
/* Most systems have these variables but do not declare them. On many
of those systems that _do_ declare them, it won't hurt */
-#if !defined(__NetBSD__) && !defined( __FreeBSD__ ) && !defined(__OpenBSD__) && !defined(__GLIBC__) && !defined(__MACH__)
+/*#if !defined(__NetBSD__) && !defined( __FreeBSD__ ) && !defined(__OpenBSD__) && !defined(__GLIBC__) && !defined(__MACH__)
extern int sys_nerr;
extern char *sys_errlist[];
-#endif
+#endif*/
/* Interactive Unix is a little bit braindead - does not have atexit(),
*/
@@ -212,6 +212,7 @@ struct tm *tm;
va_list pvar;
int errnr;
char * p;
+char *error_string;
static int first_open = TRUE;
if ( level > log_level ) /* log level high enough? */
@@ -328,12 +329,20 @@ static int first_open = TRUE;
}
else /* ERROR or FATAL */
{
+ error_string = strerror (errnr);
+ if ( error_string == NULL )
+ {
+ if ( errno == EINVAL )
+ error_string = "<error not in list>";
+ else
+ error_string = "<error calling strerror()>";
+ }
+
fprintf(log_fp, "\n%02d/%02d %02d:%02d:%02d %s %s: %s",
tm->tm_mon+1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec,
log_infix, ws,
- ( errnr <= sys_nerr ) ? sys_errlist[errnr]:
- "<error not in list>" );
+ strerror (errnr));
#ifdef SYSLOG
syslog( level == L_FATAL? LOG_ALERT: LOG_ERR, "%s: %m", ws );
#endif