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

« back to all changes in this revision

Viewing changes to unix/xc/lib/font/builtins/file.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
 * Id: file.c,v 1.2 1999/11/02 06:16:47 keithp Exp $
 
3
 *
 
4
 * Copyright 1999 SuSE, Inc.
 
5
 *
 
6
 * Permission to use, copy, modify, distribute, and sell this software and its
 
7
 * documentation for any purpose is hereby granted without fee, provided that
 
8
 * the above copyright notice appear in all copies and that both that
 
9
 * copyright notice and this permission notice appear in supporting
 
10
 * documentation, and that the name of SuSE not be used in advertising or
 
11
 * publicity pertaining to distribution of the software without specific,
 
12
 * written prior permission.  SuSE makes no representations about the
 
13
 * suitability of this software for any purpose.  It is provided "as is"
 
14
 * without express or implied warranty.
 
15
 *
 
16
 * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
 
17
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
 
18
 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 
19
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
 
20
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
 
21
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
22
 *
 
23
 * Author:  Keith Packard, SuSE, Inc.
 
24
 */
 
25
/* $XFree86: xc/lib/font/builtins/file.c,v 1.4 2000/02/23 20:29:33 dawes Exp $ */
 
26
 
 
27
#include "builtin.h"
 
28
 
 
29
typedef struct _BuiltinIO {
 
30
    int             offset;
 
31
    BuiltinFilePtr  file;
 
32
} BuiltinIORec, *BuiltinIOPtr;
 
33
 
 
34
static int
 
35
BuiltinFill (f)
 
36
    BufFilePtr  f;
 
37
{
 
38
    int     left, len;
 
39
    BuiltinIOPtr    io = ((BuiltinIOPtr) f->private);
 
40
 
 
41
    left = io->file->len - io->offset;
 
42
    if (left <= 0)
 
43
    {
 
44
        f->left = 0;
 
45
        return BUFFILEEOF;
 
46
    }
 
47
    len = BUFFILESIZE;
 
48
    if (len > left)
 
49
        len = left;
 
50
    bcopy (io->file->bits + io->offset, f->buffer, len);
 
51
    io->offset += len;
 
52
    f->left = len - 1;
 
53
    f->bufp = f->buffer + 1;
 
54
    return f->buffer[0];
 
55
}
 
56
 
 
57
static int
 
58
BuiltinSkip (f, count)
 
59
    BufFilePtr  f;
 
60
    int         count;
 
61
{
 
62
    BuiltinIOPtr    io = ((BuiltinIOPtr) f->private);
 
63
    int     curoff;
 
64
    int     fileoff;
 
65
    int     todo;
 
66
    int     left;
 
67
 
 
68
    curoff = f->bufp - f->buffer;
 
69
    fileoff = curoff + f->left;
 
70
    if (curoff + count <= fileoff) {
 
71
        f->bufp += count;
 
72
        f->left -= count;
 
73
    } else {
 
74
        todo = count - (fileoff - curoff);
 
75
        io->offset += todo;
 
76
        if (io->offset > io->file->len)
 
77
            io->offset = io->file->len;
 
78
        if (io->offset < 0)
 
79
            io->offset = 0;
 
80
        f->left = 0;
 
81
    }
 
82
    return count;
 
83
}
 
84
 
 
85
static int
 
86
BuiltinClose (f, doClose)
 
87
    BufFilePtr  f;
 
88
{
 
89
    BuiltinIOPtr    io = ((BuiltinIOPtr) f->private);
 
90
    
 
91
    xfree (io);
 
92
    return 1;
 
93
}
 
94
 
 
95
 
 
96
FontFilePtr
 
97
BuiltinFileOpen (name)
 
98
    char    *name;
 
99
{
 
100
    int             i;
 
101
    BuiltinIOPtr    io;
 
102
    BufFilePtr      raw, cooked;
 
103
 
 
104
    if (*name == '/') name++;
 
105
    for (i = 0; i < builtin_files_count; i++)
 
106
        if (!strcmp (name, builtin_files[i].name))
 
107
            break;
 
108
    if (i == builtin_files_count)
 
109
        return NULL;
 
110
    io = (BuiltinIOPtr) xalloc (sizeof (BuiltinIORec));
 
111
    if (!io)
 
112
        return NULL;
 
113
    io->offset = 0;
 
114
    io->file = (void *) &builtin_files[i];
 
115
    raw = BufFileCreate ((char *) io, BuiltinFill, 0, BuiltinSkip, BuiltinClose);
 
116
    if (!raw)
 
117
    {
 
118
        xfree (io);
 
119
        return NULL;
 
120
    }
 
121
    if (cooked = BufFilePushCompressed (raw))
 
122
        raw = cooked;
 
123
    else
 
124
    {
 
125
        raw->left += raw->bufp - raw->buffer;
 
126
        raw->bufp = raw->buffer;
 
127
    }
 
128
    return (FontFilePtr) raw;
 
129
}
 
130
 
 
131
BuiltinFileClose (f)
 
132
    FontFilePtr f;
 
133
{
 
134
    return BufFileClose ((BufFilePtr) f, TRUE);
 
135
}