aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNigel Tao <nigeltao@golang.org>2010-10-09 11:22:14 +1100
committerNigel Tao <nigeltao@golang.org>2010-10-09 11:22:14 +1100
commitfd311cb14495d0ab7ef2fd37864734dbb514a2c7 (patch)
tree88b3919e1bf6038e1f921adc34be7833c1de70df
parented575dc2b98e2cba415f0c07736ff7cff53a5280 (diff)
downloadgo-fd311cb14495d0ab7ef2fd37864734dbb514a2c7.tar.gz
go-fd311cb14495d0ab7ef2fd37864734dbb514a2c7.zip
exp/draw/x11: support X11 vendors other than "The X.Org Foundation".
R=adg, ehog.hedge CC=golang-dev https://golang.org/cl/2385041
-rw-r--r--src/pkg/exp/draw/x11/conn.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/pkg/exp/draw/x11/conn.go b/src/pkg/exp/draw/x11/conn.go
index 70c2ee2d83..fdf6281b41 100644
--- a/src/pkg/exp/draw/x11/conn.go
+++ b/src/pkg/exp/draw/x11/conn.go
@@ -489,16 +489,13 @@ func (c *conn) handshake() os.Error {
if err != nil {
return err
}
- // Read the vendor length.
+ // Read the vendor length and round it up to a multiple of 4,
+ // for X11 protocol alignment reasons.
vendorLen, err := readU16LE(c.r, c.buf[0:2])
if err != nil {
return err
}
- if vendorLen != 20 {
- // For now, assume the vendor is "The X.Org Foundation". Supporting different
- // vendors would require figuring out how much padding we need to read.
- return os.NewError("unsupported X vendor")
- }
+ vendorLen = (vendorLen + 3) &^ 3
// Read the maximum request length.
maxReqLen, err := readU16LE(c.r, c.buf[0:2])
if err != nil {
@@ -517,10 +514,13 @@ func (c *conn) handshake() os.Error {
if err != nil {
return err
}
- // Ignore some things that we don't care about (totalling 30 bytes):
+ // Ignore some things that we don't care about (totalling 10 + vendorLen bytes):
// imageByteOrder(1), bitmapFormatBitOrder(1), bitmapFormatScanlineUnit(1) bitmapFormatScanlinePad(1),
- // minKeycode(1), maxKeycode(1), padding(4), vendor(20, hard-coded above).
- _, err = io.ReadFull(c.r, c.buf[0:30])
+ // minKeycode(1), maxKeycode(1), padding(4), vendor (vendorLen).
+ if 10+int(vendorLen) > cap(c.buf) {
+ return os.NewError("unsupported X vendor")
+ }
+ _, err = io.ReadFull(c.r, c.buf[0:10+int(vendorLen)])
if err != nil {
return err
}