~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/lib/GL/mesa/src/drv/sis/sis_debug.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************
 
2
 
 
3
Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
 
4
All Rights Reserved.
 
5
 
 
6
Permission is hereby granted, free of charge, to any person obtaining a
 
7
copy of this software and associated documentation files (the
 
8
"Software"), to deal in the Software without restriction, including
 
9
without limitation the rights to use, copy, modify, merge, publish,
 
10
distribute, sub license, and/or sell copies of the Software, and to
 
11
permit persons to whom the Software is furnished to do so, subject to
 
12
the following conditions:
 
13
 
 
14
The above copyright notice and this permission notice (including the
 
15
next paragraph) shall be included in all copies or substantial portions
 
16
of the Software.
 
17
 
 
18
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
19
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
20
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 
21
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
 
22
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 
23
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 
24
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
25
 
 
26
**************************************************************************/
 
27
/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_debug.c,v 1.5 2000/09/26 15:56:48 tsi Exp $ */
 
28
 
 
29
/*
 
30
 * Authors:
 
31
 *    Sung-Ching Lin <sclin@sis.com.tw>
 
32
 *
 
33
 */
 
34
 
 
35
/* 
 
36
 * dump HW states, set environment variable SIS_DEBUG
 
37
 * to enable these functions 
 
38
 */
 
39
 
 
40
#include <fcntl.h>
 
41
#include <assert.h>
 
42
 
 
43
#include "sis_ctx.h"
 
44
#include "sis_mesa.h"
 
45
 
 
46
/* for SiS 300/630/540 */
 
47
#define MMIOLength (0x8FFF-0x8800+1)
 
48
#define MMIO3DOffset (0x8800)
 
49
#define FILE_NAME "300.dump"
 
50
 
 
51
char *IOBase4Debug = 0;
 
52
 
 
53
char *prevLockFile = NULL;
 
54
int prevLockLine = 0;
 
55
 
 
56
DWORD _empty[0x10000];
 
57
 
 
58
void
 
59
dump_agp (void *addr, int dword_count)
 
60
{
 
61
  if (!getenv ("SIS_DEBUG"))
 
62
    return;
 
63
 
 
64
  {
 
65
    int i;
 
66
    FILE *file = fopen ("300agp.dump", "w");
 
67
 
 
68
    if (file)
 
69
      {
 
70
        for (i = 0; i < dword_count; i++)
 
71
          {
 
72
            fprintf (file, "%f\n", *(float *) addr);
 
73
            ((unsigned char *) addr) += 4;
 
74
          }
 
75
        fclose (file);
 
76
      }
 
77
  }
 
78
}
 
79
 
 
80
void
 
81
d2f_once (GLcontext * ctx)
 
82
{
 
83
  XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
 
84
  __GLSiScontext *hwcx = (__GLSiScontext *) xmesa->private;
 
85
 
 
86
  static int serialNumber = -1;
 
87
 
 
88
  if (serialNumber == hwcx->serialNumber)
 
89
    return;
 
90
  else
 
91
    serialNumber = hwcx->serialNumber;
 
92
 
 
93
  d2f();
 
94
}
 
95
 
 
96
void
 
97
d2f (void)
 
98
{
 
99
  if (!getenv ("SIS_DEBUG"))
 
100
    return;
 
101
 
 
102
  /* dump 0x8800 - 0x8AFF */
 
103
  {
 
104
    int fh;
 
105
    int rval;
 
106
    void *addr = IOBase4Debug + MMIO3DOffset;
 
107
 
 
108
    assert (IOBase4Debug);
 
109
 
 
110
    if ((fh = open (FILE_NAME, O_WRONLY | O_CREAT, S_IREAD | S_IWRITE)) != -1)
 
111
      {
 
112
        rval = write (fh, addr, MMIOLength);
 
113
        assert (rval != -1);
 
114
        close (fh);
 
115
      }
 
116
  }
 
117
}
 
118
 
 
119
/* dump to HW */
 
120
void
 
121
d2h (char *file_name)
 
122
{
 
123
  int fh;
 
124
  int rval;
 
125
  void *addr[MMIOLength];
 
126
 
 
127
  if (!getenv ("SIS_DEBUG"))
 
128
    return;
 
129
 
 
130
  if ((fh = open (file_name, O_CREAT, S_IREAD | S_IWRITE)) != -1)
 
131
    {
 
132
      rval = read (fh, addr, MMIOLength);
 
133
      assert (rval != -1);
 
134
      close (fh);
 
135
    }
 
136
  memcpy (IOBase4Debug + MMIO3DOffset, addr, MMIOLength);
 
137
 
 
138
}
 
139
 
 
140
/* dump video memory to file  */
 
141
void
 
142
dvidmem (unsigned char *addr, int size)
 
143
{
 
144
  int fh;
 
145
  int rval;
 
146
  static char *file_name = "vidmem.dump";
 
147
 
 
148
  if (!getenv ("SIS_DEBUG"))
 
149
    return;
 
150
 
 
151
  if ((fh = open (file_name, O_WRONLY | O_CREAT, S_IREAD | S_IWRITE)) != -1)
 
152
    {
 
153
      rval = write (fh, addr, size);
 
154
      assert (rval != -1);
 
155
      close (fh);
 
156
    }
 
157
}