tech-crypto archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

OpenSSH enum patch



OpenSSH defines enums for syslog facilities and levels, but assumes (e.g.
in log_facility_number and log_level_number), that it's OK to cast -1 to a
value of this type, even though -1 isn't a member of either enum.  This
may stop working on NetBSD/arm sometime soon.

A simple fix to this is below.  It would be better if the extra value had
a more descriptive name, and if it were used by name everywhere rather
than hardcoding -1, but this fix is enough to get the code to compile
correctly with -fshort-enums.

Index: crypto/dist/ssh/log.h
===================================================================
RCS file: /cvsroot/basesrc/crypto/dist/ssh/log.h,v
retrieving revision 1.3
diff -u -r1.3 log.h
--- crypto/dist/ssh/log.h       2001/09/27 03:24:03     1.3
+++ crypto/dist/ssh/log.h       2002/01/03 22:34:26
@@ -28,7 +28,8 @@
        SYSLOG_FACILITY_LOCAL4,
        SYSLOG_FACILITY_LOCAL5,
        SYSLOG_FACILITY_LOCAL6,
-       SYSLOG_FACILITY_LOCAL7
+       SYSLOG_FACILITY_LOCAL7,
+       SYSLOG_FACILITY_MINUSONE = -1
 }       SyslogFacility;

 typedef enum {
@@ -39,7 +40,8 @@
        SYSLOG_LEVEL_VERBOSE,
        SYSLOG_LEVEL_DEBUG1,
        SYSLOG_LEVEL_DEBUG2,
-       SYSLOG_LEVEL_DEBUG3
+       SYSLOG_LEVEL_DEBUG3,
+       SYSLOG_LEVEL_MINUSONE = -1
 }       LogLevel;

 void     log_init(char *, LogLevel, SyslogFacility, int);

-- 
Ben Harris                                                   
<bjh21%netbsd.org@localhost>
Portmaster, NetBSD/arm26               <URL:http://www.netbsd.org/Ports/arm26/>




Home | Main Index | Thread Index | Old Index