Commit 9629d799 authored by Eric Sandeen's avatar Eric Sandeen Committed by Nathan Scott

[XFS] Make sure we don't walk off the end of the err_level array

SGI Modid: 2.5.x-xfs:slinx:135827a
parent 9552d6bc
...@@ -41,7 +41,9 @@ static char message[256]; /* keep it off the stack */ ...@@ -41,7 +41,9 @@ static char message[256]; /* keep it off the stack */
static spinlock_t xfs_err_lock = SPIN_LOCK_UNLOCKED; static spinlock_t xfs_err_lock = SPIN_LOCK_UNLOCKED;
/* Translate from CE_FOO to KERN_FOO, err_level(CE_FOO) == KERN_FOO */ /* Translate from CE_FOO to KERN_FOO, err_level(CE_FOO) == KERN_FOO */
static char *err_level[8] = {KERN_EMERG, KERN_ALERT, KERN_CRIT, #define MAX_XFS_ERR_LEVEL 7
static char *err_level[XFS_MAX_ERR_LEVEL+1] =
{KERN_EMERG, KERN_ALERT, KERN_CRIT,
KERN_ERR, KERN_WARNING, KERN_NOTICE, KERN_ERR, KERN_WARNING, KERN_NOTICE,
KERN_INFO, KERN_DEBUG}; KERN_INFO, KERN_DEBUG};
...@@ -84,6 +86,8 @@ cmn_err(register int level, char *fmt, ...) ...@@ -84,6 +86,8 @@ cmn_err(register int level, char *fmt, ...)
char *fp = fmt; char *fp = fmt;
va_list ap; va_list ap;
if (level > XFS_MAX_ERR_LEVEL)
level = XFS_MAX_ERR_LEVEL;
spin_lock(&xfs_err_lock); spin_lock(&xfs_err_lock);
va_start(ap, fmt); va_start(ap, fmt);
if (*fmt == '!') fp++; if (*fmt == '!') fp++;
...@@ -100,6 +104,8 @@ cmn_err(register int level, char *fmt, ...) ...@@ -100,6 +104,8 @@ cmn_err(register int level, char *fmt, ...)
void void
icmn_err(register int level, char *fmt, va_list ap) icmn_err(register int level, char *fmt, va_list ap)
{ {
if (level > XFS_MAX_ERR_LEVEL)
level = XFS_MAX_ERR_LEVEL;
spin_lock(&xfs_err_lock); spin_lock(&xfs_err_lock);
vsprintf(message, fmt, ap); vsprintf(message, fmt, ap);
spin_unlock(&xfs_err_lock); spin_unlock(&xfs_err_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment