Commit f5348bdc authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

X.Org bug 4947/Sun bug 6646626: Xv extension not byte-swapping properly

Fixes ArcticaProject/nx-libs#165 commit dfd682b582636a36345144bcf835e3ee46718d90 Author: Alan Coopersmith <alan.coopersmith@sun.com> Date: Wed Jan 2 19:27:22 2008 -0800 X.Org bug 4947/Sun bug 6646626: Xv extension not byte-swapping properly X.Org Bugzilla #4947 <https://bugs.freedesktop.org/show_bug.cgi?id=4947> Sun bug 6646626 <http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6646626> Don't use swapped data after swapping it. When done swapping data, send the swapped data, not the address of the pointer to it, to the client.
parent a894fa8b
...@@ -387,6 +387,7 @@ ProcXvQueryAdaptors(ClientPtr client) ...@@ -387,6 +387,7 @@ ProcXvQueryAdaptors(ClientPtr client)
xvAdaptorInfo ainfo; xvAdaptorInfo ainfo;
xvQueryAdaptorsReply rep; xvQueryAdaptorsReply rep;
int totalSize, na, nf; int totalSize, na, nf;
int nameSize;
XvAdaptorPtr pa; XvAdaptorPtr pa;
XvFormatPtr pf; XvFormatPtr pf;
WindowPtr pWin; WindowPtr pWin;
...@@ -450,12 +451,12 @@ ProcXvQueryAdaptors(ClientPtr client) ...@@ -450,12 +451,12 @@ ProcXvQueryAdaptors(ClientPtr client)
ainfo.base_id = pa->base_id; ainfo.base_id = pa->base_id;
ainfo.num_ports = pa->nPorts; ainfo.num_ports = pa->nPorts;
ainfo.type = pa->type; ainfo.type = pa->type;
ainfo.name_size = strlen(pa->name); ainfo.name_size = nameSize = strlen(pa->name);
ainfo.num_formats = pa->nFormats; ainfo.num_formats = pa->nFormats;
_WriteAdaptorInfo(client, &ainfo); _WriteAdaptorInfo(client, &ainfo);
WriteToClient(client, ainfo.name_size, pa->name); WriteToClient(client, nameSize, pa->name);
nf = pa->nFormats; nf = pa->nFormats;
pf = pa->pFormats; pf = pa->pFormats;
...@@ -481,6 +482,7 @@ ProcXvQueryEncodings(ClientPtr client) ...@@ -481,6 +482,7 @@ ProcXvQueryEncodings(ClientPtr client)
xvEncodingInfo einfo; xvEncodingInfo einfo;
xvQueryEncodingsReply rep; xvQueryEncodingsReply rep;
int totalSize; int totalSize;
int nameSize;
XvPortPtr pPort; XvPortPtr pPort;
int ne; int ne;
XvEncodingPtr pe; XvEncodingPtr pe;
...@@ -525,13 +527,13 @@ ProcXvQueryEncodings(ClientPtr client) ...@@ -525,13 +527,13 @@ ProcXvQueryEncodings(ClientPtr client)
while (ne--) while (ne--)
{ {
einfo.encoding = pe->id; einfo.encoding = pe->id;
einfo.name_size = strlen(pe->name); einfo.name_size = nameSize = strlen(pe->name);
einfo.width = pe->width; einfo.width = pe->width;
einfo.height = pe->height; einfo.height = pe->height;
einfo.rate.numerator = pe->rate.numerator; einfo.rate.numerator = pe->rate.numerator;
einfo.rate.denominator = pe->rate.denominator; einfo.rate.denominator = pe->rate.denominator;
_WriteEncodingInfo(client, &einfo); _WriteEncodingInfo(client, &einfo);
WriteToClient(client, einfo.name_size, pe->name); WriteToClient(client, nameSize, pe->name);
pe++; pe++;
} }
...@@ -1011,19 +1013,20 @@ ProcXvQueryPortAttributes(ClientPtr client) ...@@ -1011,19 +1013,20 @@ ProcXvQueryPortAttributes(ClientPtr client)
rep.num_attributes = pPort->pAdaptor->nAttributes; rep.num_attributes = pPort->pAdaptor->nAttributes;
rep.text_size = 0; rep.text_size = 0;
for(i = 0, pAtt = pPort->pAdaptor->pAttributes; for(i = 0, pAtt = pPort->pAdaptor->pAttributes;
i < rep.num_attributes; i++, pAtt++) i < pPort->pAdaptor->nAttributes; i++, pAtt++)
{ {
rep.text_size += (strlen(pAtt->name) + 1 + 3) & ~3L; rep.text_size += (strlen(pAtt->name) + 1 + 3) & ~3L;
} }
rep.length = (rep.num_attributes * sz_xvAttributeInfo) + rep.text_size; rep.length = (pPort->pAdaptor->nAttributes * sz_xvAttributeInfo)
+ rep.text_size;
rep.length >>= 2; rep.length >>= 2;
_WriteQueryPortAttributesReply(client, &rep); _WriteQueryPortAttributesReply(client, &rep);
for(i = 0, pAtt = pPort->pAdaptor->pAttributes; for(i = 0, pAtt = pPort->pAdaptor->pAttributes;
i < rep.num_attributes; i++, pAtt++) i < pPort->pAdaptor->nAttributes; i++, pAtt++)
{ {
size = strlen(pAtt->name) + 1; /* pass the NULL */ size = strlen(pAtt->name) + 1; /* pass the NULL */
Info.flags = pAtt->flags; Info.flags = pAtt->flags;
...@@ -1233,6 +1236,7 @@ ProcXvQueryImageAttributes(ClientPtr client) ...@@ -1233,6 +1236,7 @@ ProcXvQueryImageAttributes(ClientPtr client)
XvPortPtr pPort; XvPortPtr pPort;
int *offsets; int *offsets;
int *pitches; int *pitches;
int planeLength;
REQUEST(xvQueryImageAttributesReq); REQUEST(xvQueryImageAttributesReq);
REQUEST_SIZE_MATCH(xvQueryImageAttributesReq); REQUEST_SIZE_MATCH(xvQueryImageAttributesReq);
...@@ -1272,7 +1276,7 @@ ProcXvQueryImageAttributes(ClientPtr client) ...@@ -1272,7 +1276,7 @@ ProcXvQueryImageAttributes(ClientPtr client)
rep.type = X_Reply; rep.type = X_Reply;
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
rep.length = num_planes << 1; rep.length = planeLength = num_planes << 1;
rep.num_planes = num_planes; rep.num_planes = num_planes;
rep.width = width; rep.width = width;
rep.height = height; rep.height = height;
...@@ -1280,8 +1284,8 @@ ProcXvQueryImageAttributes(ClientPtr client) ...@@ -1280,8 +1284,8 @@ ProcXvQueryImageAttributes(ClientPtr client)
_WriteQueryImageAttributesReply(client, &rep); _WriteQueryImageAttributesReply(client, &rep);
if(client->swapped) if(client->swapped)
SwapLongs((CARD32*)offsets, rep.length); SwapLongs((CARD32*)offsets, planeLength);
WriteToClient(client, rep.length << 2, offsets); WriteToClient(client, planeLength << 2, offsets);
free(offsets); free(offsets);
...@@ -1309,13 +1313,13 @@ ProcXvListImageFormats(ClientPtr client) ...@@ -1309,13 +1313,13 @@ ProcXvListImageFormats(ClientPtr client)
rep.type = X_Reply; rep.type = X_Reply;
rep.sequenceNumber = client->sequence; rep.sequenceNumber = client->sequence;
rep.num_formats = pPort->pAdaptor->nImages; rep.num_formats = pPort->pAdaptor->nImages;
rep.length = rep.num_formats * sz_xvImageFormatInfo >> 2; rep.length = pPort->pAdaptor->nImages * sz_xvImageFormatInfo >> 2;
_WriteListImageFormatsReply(client, &rep); _WriteListImageFormatsReply(client, &rep);
pImage = pPort->pAdaptor->pImages; pImage = pPort->pAdaptor->pImages;
for(i = 0; i < rep.num_formats; i++, pImage++) { for(i = 0; i < pPort->pAdaptor->nImages; i++, pImage++) {
info.id = pImage->id; info.id = pImage->id;
info.type = pImage->type; info.type = pImage->type;
info.byte_order = pImage->byte_order; info.byte_order = pImage->byte_order;
...@@ -1642,7 +1646,7 @@ SWriteQueryExtensionReply( ...@@ -1642,7 +1646,7 @@ SWriteQueryExtensionReply(
swaps(&rep->version); swaps(&rep->version);
swaps(&rep->revision); swaps(&rep->revision);
WriteToClient(client, sz_xvQueryExtensionReply, &rep); WriteToClient(client, sz_xvQueryExtensionReply, rep);
return Success; return Success;
} }
...@@ -1656,7 +1660,7 @@ SWriteQueryAdaptorsReply( ...@@ -1656,7 +1660,7 @@ SWriteQueryAdaptorsReply(
swapl(&rep->length); swapl(&rep->length);
swaps(&rep->num_adaptors); swaps(&rep->num_adaptors);
WriteToClient(client, sz_xvQueryAdaptorsReply, &rep); WriteToClient(client, sz_xvQueryAdaptorsReply, rep);
return Success; return Success;
} }
...@@ -1670,7 +1674,7 @@ SWriteQueryEncodingsReply( ...@@ -1670,7 +1674,7 @@ SWriteQueryEncodingsReply(
swapl(&rep->length); swapl(&rep->length);
swaps(&rep->num_encodings); swaps(&rep->num_encodings);
WriteToClient(client, sz_xvQueryEncodingsReply, &rep); WriteToClient(client, sz_xvQueryEncodingsReply, rep);
return Success; return Success;
} }
...@@ -1765,7 +1769,7 @@ SWriteGrabPortReply( ...@@ -1765,7 +1769,7 @@ SWriteGrabPortReply(
swaps(&rep->sequenceNumber); swaps(&rep->sequenceNumber);
swapl(&rep->length); swapl(&rep->length);
WriteToClient(client, sz_xvGrabPortReply, &rep); WriteToClient(client, sz_xvGrabPortReply, rep);
return Success; return Success;
} }
...@@ -1779,7 +1783,7 @@ SWriteGetPortAttributeReply( ...@@ -1779,7 +1783,7 @@ SWriteGetPortAttributeReply(
swapl(&rep->length); swapl(&rep->length);
swapl(&rep->value); swapl(&rep->value);
WriteToClient(client, sz_xvGetPortAttributeReply, &rep); WriteToClient(client, sz_xvGetPortAttributeReply, rep);
return Success; return Success;
} }
...@@ -1794,7 +1798,7 @@ SWriteQueryBestSizeReply( ...@@ -1794,7 +1798,7 @@ SWriteQueryBestSizeReply(
swaps(&rep->actual_width); swaps(&rep->actual_width);
swaps(&rep->actual_height); swaps(&rep->actual_height);
WriteToClient(client, sz_xvQueryBestSizeReply, &rep); WriteToClient(client, sz_xvQueryBestSizeReply, rep);
return Success; return Success;
} }
...@@ -1809,7 +1813,7 @@ SWriteQueryPortAttributesReply( ...@@ -1809,7 +1813,7 @@ SWriteQueryPortAttributesReply(
swapl(&rep->num_attributes); swapl(&rep->num_attributes);
swapl(&rep->text_size); swapl(&rep->text_size);
WriteToClient(client, sz_xvQueryPortAttributesReply, &rep); WriteToClient(client, sz_xvQueryPortAttributesReply, rep);
return Success; return Success;
} }
...@@ -1826,7 +1830,7 @@ SWriteQueryImageAttributesReply( ...@@ -1826,7 +1830,7 @@ SWriteQueryImageAttributesReply(
swaps(&rep->width); swaps(&rep->width);
swaps(&rep->height); swaps(&rep->height);
WriteToClient(client, sz_xvQueryImageAttributesReply, &rep); WriteToClient(client, sz_xvQueryImageAttributesReply, rep);
return Success; return Success;
} }
...@@ -1841,7 +1845,7 @@ SWriteListImageFormatsReply( ...@@ -1841,7 +1845,7 @@ SWriteListImageFormatsReply(
swapl(&rep->length); swapl(&rep->length);
swapl(&rep->num_formats); swapl(&rep->num_formats);
WriteToClient(client, sz_xvListImageFormatsReply, &rep); WriteToClient(client, sz_xvListImageFormatsReply, rep);
return Success; return Success;
} }
......
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