diff options
author | Alan Coopersmith <Alan.Coopersmith@sun.com> | 2006-03-11 02:10:14 +0000 |
---|---|---|
committer | Alan Coopersmith <Alan.Coopersmith@sun.com> | 2006-03-11 02:10:14 +0000 |
commit | fc0772de36315f19f5b57220db69f48a3b1fdc9a (patch) | |
tree | 695349cb0e0d0e54ac1bf9f4bcc629c24e15969f | |
parent | f2ecbb30187000547a98ca7cbaee433ea4ba8fe3 (diff) |
Add HAS_MMAP for Xvfb
Fix Xvfb option parsing to exit on bad arguments, not just issue error
messages and continue on. (Coverity #492)
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | hw/vfb/InitOutput.c | 35 | ||||
-rw-r--r-- | include/dix-config.h.in | 3 |
4 files changed, 40 insertions, 11 deletions
@@ -1,5 +1,15 @@ 2006-03-10 Alan Coopersmith <alan.coopersmith@sun.com> + * configure.ac: + * include/dix-config.h.in: + Add HAS_MMAP for Xvfb + + * hw/vfb/InitOutput.c (ddxProcessArgument): + Fix Xvfb option parsing to exit on bad arguments, not just issue + error messages and continue on. (Coverity #492) + +2006-03-10 Alan Coopersmith <alan.coopersmith@sun.com> + * hw/xfree86/utils/xorgcfg/options.c: Pass sizeof the correct buffer to XmuSnprintf. (Coverity #489) diff --git a/configure.ac b/configure.ac index 02032da9a..a8971dbbe 100644 --- a/configure.ac +++ b/configure.ac @@ -98,6 +98,9 @@ AM_CONDITIONAL(NEED_STRLCAT, [test x$HAVE_STRLCAT = xno]) AM_CONDITIONAL(NEED_VSNPRINTF, [test x$HAVE_VSNPRINTF = xno]) +dnl Check for mmap support for Xvfb +AC_CHECK_FUNC([mmap], AC_DEFINE(HAS_MMAP, 1, [Have the `mmap' function.])) + dnl Find the math libary AC_CHECK_LIB(m, sqrt) diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c index a7d50db19..86e3fbe14 100644 --- a/hw/vfb/InitOutput.c +++ b/hw/vfb/InitOutput.c @@ -299,15 +299,24 @@ ddxProcessArgument(int argc, char *argv[], int i) firstTime = FALSE; } +#define CHECK_FOR_REQUIRED_ARGUMENTS(num) \ + if (((i + num) >= argc) || (!argv[i + num])) { \ + ErrorF("Required argument to %s not specified\n", argv[i]); \ + UseMsg(); \ + FatalError("Required argument to %s not specified\n", argv[i]); \ + } + if (strcmp (argv[i], "-screen") == 0) /* -screen n WxHxD */ { int screenNum; - if (i + 2 >= argc) UseMsg(); + CHECK_FOR_REQUIRED_ARGUMENTS(2); screenNum = atoi(argv[i+1]); if (screenNum < 0 || screenNum >= MAXSCREENS) { ErrorF("Invalid screen number %d\n", screenNum); UseMsg(); + FatalError("Invalid screen number %d passed to -screen\n", + screenNum); } if (3 != sscanf(argv[i+2], "%dx%dx%d", &vfbScreens[screenNum].width, @@ -316,6 +325,8 @@ ddxProcessArgument(int argc, char *argv[], int i) { ErrorF("Invalid screen configuration %s\n", argv[i+2]); UseMsg(); + FatalError("Invalid screen configuration %s for -screen %d\n", + argv[i+2], screenNum); } if (screenNum >= vfbNumScreens) @@ -328,13 +339,15 @@ ddxProcessArgument(int argc, char *argv[], int i) { int depth, ret = 1; - if (++i >= argc) UseMsg(); - while ((i < argc) && (depth = atoi(argv[i++])) != 0) + CHECK_FOR_REQUIRED_ARGUMENTS(1); + while ((++i < argc) && (depth = atoi(argv[i])) != 0) { if (depth < 0 || depth > 32) { ErrorF("Invalid pixmap depth %d\n", depth); UseMsg(); + FatalError("Invalid pixmap depth %d passed to -pixdepths\n", + depth); } vfbPixmapDepths[depth] = TRUE; ret++; @@ -357,8 +370,8 @@ ddxProcessArgument(int argc, char *argv[], int i) if (strcmp (argv[i], "-blackpixel") == 0) /* -blackpixel n */ { Pixel pix; - if (++i >= argc) UseMsg(); - pix = atoi(argv[i]); + CHECK_FOR_REQUIRED_ARGUMENTS(1); + pix = atoi(argv[++i]); if (-1 == lastScreen) { int i; @@ -377,8 +390,8 @@ ddxProcessArgument(int argc, char *argv[], int i) if (strcmp (argv[i], "-whitepixel") == 0) /* -whitepixel n */ { Pixel pix; - if (++i >= argc) UseMsg(); - pix = atoi(argv[i]); + CHECK_FOR_REQUIRED_ARGUMENTS(1); + pix = atoi(argv[++i]); if (-1 == lastScreen) { int i; @@ -397,8 +410,8 @@ ddxProcessArgument(int argc, char *argv[], int i) if (strcmp (argv[i], "-linebias") == 0) /* -linebias n */ { unsigned int linebias; - if (++i >= argc) UseMsg(); - linebias = atoi(argv[i]); + CHECK_FOR_REQUIRED_ARGUMENTS(1); + linebias = atoi(argv[++i]); if (-1 == lastScreen) { int i; @@ -417,8 +430,8 @@ ddxProcessArgument(int argc, char *argv[], int i) #ifdef HAS_MMAP if (strcmp (argv[i], "-fbdir") == 0) /* -fbdir directory */ { - if (++i >= argc) UseMsg(); - pfbdir = argv[i]; + CHECK_FOR_REQUIRED_ARGUMENTS(1); + pfbdir = argv[++i]; fbmemtype = MMAPPED_FILE_FB; return 2; } diff --git a/include/dix-config.h.in b/include/dix-config.h.in index 4ee747726..0e3f8f985 100644 --- a/include/dix-config.h.in +++ b/include/dix-config.h.in @@ -71,6 +71,9 @@ /* Define to 1 if you have the `getpeerucred' function. */ #undef HAS_GETPEERUCRED +/* Define to 1 if you have the `mmap' function. */ +#undef HAS_MMAP + /* Support SHM */ #undef HAS_SHM |