summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@neko.keithp.com>2007-07-14 12:13:17 -0700
committerKeith Packard <keithp@neko.keithp.com>2007-07-14 12:13:17 -0700
commitac979c165128704116cd40086320b6edc79018e2 (patch)
treec8ec58359023af8eccb93ab6e651793ffef2d21f
parent393171034c15d8a1b82232b8f9455a358035e932 (diff)
MakeAtom needs length without trailing NUL. sizeof("string") includes NUL.
I made a mistake in some new code using MakeAtom, passing the size of the string instead of the length of the string. Figuring there might be other such mistakes, I reviewed the server code and found four bugs of the same form.
-rw-r--r--hw/xfree86/common/xf86Init.c2
-rw-r--r--hw/xfree86/ddc/ddcProperty.c4
-rw-r--r--hw/xfree86/modes/xf86Crtc.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index d098e13fd..c0775d163 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -740,7 +740,7 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
}
*VT = xf86Info.vtno;
- VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME), TRUE);
+ VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE);
for (i = 0, ret = Success; i < xf86NumScreens && ret == Success; i++) {
ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
diff --git a/hw/xfree86/ddc/ddcProperty.c b/hw/xfree86/ddc/ddcProperty.c
index 6ff0726d9..67351d3dc 100644
--- a/hw/xfree86/ddc/ddcProperty.c
+++ b/hw/xfree86/ddc/ddcProperty.c
@@ -87,7 +87,7 @@ addRootWindowProperties(ScrnInfoPtr pScrn, xf86MonPtr DDC)
if ((EDID1rawdata = xalloc(128*sizeof(CARD8)))==NULL)
return;
- EDID1Atom = MakeAtom(EDID1_ATOM_NAME, sizeof(EDID1_ATOM_NAME), TRUE);
+ EDID1Atom = MakeAtom(EDID1_ATOM_NAME, sizeof(EDID1_ATOM_NAME) - 1, TRUE);
memcpy(EDID1rawdata, DDC->rawData, 128);
xf86RegisterRootWindowProperty(scrnIndex, EDID1Atom, XA_INTEGER, 8,
128, (unsigned char *)EDID1rawdata);
@@ -98,7 +98,7 @@ addRootWindowProperties(ScrnInfoPtr pScrn, xf86MonPtr DDC)
return;
memcpy(EDID2rawdata, DDC->rawData, 256);
- EDID2Atom = MakeAtom(EDID2_ATOM_NAME, sizeof(EDID2_ATOM_NAME), TRUE);
+ EDID2Atom = MakeAtom(EDID2_ATOM_NAME, sizeof(EDID2_ATOM_NAME) - 1, TRUE);
xf86RegisterRootWindowProperty(scrnIndex, EDID2Atom, XA_INTEGER, 8,
256, (unsigned char *)EDID2rawdata);
}
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 722b62be4..ecdf62048 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -2031,7 +2031,7 @@ xf86DisableUnusedFunctions(ScrnInfoPtr pScrn)
static void
xf86OutputSetEDIDProperty (xf86OutputPtr output, void *data, int data_len)
{
- Atom edid_atom = MakeAtom(EDID_ATOM_NAME, sizeof(EDID_ATOM_NAME), TRUE);
+ Atom edid_atom = MakeAtom(EDID_ATOM_NAME, sizeof(EDID_ATOM_NAME) - 1, TRUE);
/* This may get called before the RandR resources have been created */
if (output->randr_output == NULL)