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

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/os-support/hurd/bios_mmap.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
 * Copyright 1997 by UCHIYAMA Yasushi
 
3
 *
 
4
 * Permission to use, copy, modify, distribute, and sell this software and its
 
5
 * documentation for any purpose is hereby granted without fee, provided that
 
6
 * the above copyright notice appear in all copies and that both that
 
7
 * copyright notice and this permission notice appear in supporting
 
8
 * documentation, and that the name of UCHIYAMA Yasushi not be used in
 
9
 * advertising or publicity pertaining to distribution of the software without
 
10
 * specific, written prior permission.  UCHIYAMA Yasushi makes no representations
 
11
 * about the suitability of this software for any purpose.  It is provided
 
12
 * "as is" without express or implied warranty.
 
13
 *
 
14
 * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
15
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 
16
 * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
17
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
18
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
19
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
20
 * PERFORMANCE OF THIS SOFTWARE.
 
21
 *
 
22
 */
 
23
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/bios_mmap.c,v 1.1 1998/08/16 10:25:47 dawes Exp $ */
 
24
#include<mach.h>
 
25
#include<device/device.h>
 
26
 
 
27
#include "X.h"
 
28
 
 
29
#include "xf86.h"
 
30
#include "xf86Priv.h"
 
31
#include "xf86_OSlib.h"
 
32
 
 
33
#define BIOS_SIZE 0x20000
 
34
 
 
35
int 
 
36
xf86ReadBIOS(unsigned long Base,unsigned long Offset,unsigned char *Buf,int Len)
 
37
{
 
38
    mach_port_t device,iopl_dev;
 
39
    memory_object_t iopl_mem;
 
40
    vm_address_t addr = (vm_address_t)0; /* serach starting address */
 
41
    kern_return_t err;
 
42
 
 
43
 
 
44
    err = get_privileged_ports (NULL, &device);
 
45
    if( err )
 
46
    {
 
47
        errno = err;
 
48
        FatalError("xf86ReadBIOS() can't get_privileged_ports. (%s)\n",strerror(errno));
 
49
    }
 
50
    err = device_open(device,D_READ|D_WRITE,"iopl",&iopl_dev);
 
51
    mach_port_deallocate (mach_task_self (), device);
 
52
    if( err )
 
53
    {
 
54
        errno = err;
 
55
        FatalError("xf86ReadBIOS() can't device_open. (%s)\n",strerror(errno));
 
56
    }
 
57
    err = device_map(iopl_dev,VM_PROT_READ|VM_PROT_WRITE, Base , BIOS_SIZE ,&iopl_mem,0);
 
58
    if( err )
 
59
    {
 
60
        errno = err;
 
61
        FatalError("xf86ReadBIOS() can't device_map. (%s)\n",strerror(errno));
 
62
    }
 
63
    err = vm_map(mach_task_self(),
 
64
                 &addr,
 
65
                 BIOS_SIZE,
 
66
                 0,
 
67
                 TRUE,
 
68
                 iopl_mem,
 
69
                 Base,
 
70
                 FALSE,
 
71
                 VM_PROT_READ|VM_PROT_WRITE,
 
72
                 VM_PROT_READ|VM_PROT_WRITE,
 
73
                 VM_INHERIT_SHARE);
 
74
    mach_port_deallocate(mach_task_self(),iopl_mem);
 
75
    if( err )
 
76
    {
 
77
        errno = err;
 
78
        FatalError("xf86ReadBIOS() can't vm_map. (%s)\n",strerror(errno));
 
79
    }
 
80
 
 
81
    memcpy(Buf,(void*)((int)addr + Offset), Len);
 
82
    
 
83
    err = vm_deallocate(mach_task_self(), addr, BIOS_SIZE);
 
84
    if( err )
 
85
    {
 
86
        errno = err;
 
87
        FatalError("xf86ReadBIOS() can't vm_deallocate. (%s)\n",strerror(errno));
 
88
    }
 
89
    
 
90
    return Len;
 
91
}