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

« back to all changes in this revision

Viewing changes to unix/xc/programs/bdftopcf/bdftopcf.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
/* $Xorg: bdftopcf.c,v 1.4 2001/02/09 02:05:28 xorgcvs Exp $ */
 
2
/*
 
3
 
 
4
Copyright 1991, 1993, 1998  The Open Group
 
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.
 
11
 
 
12
The above copyright notice and this permission notice shall be included
 
13
in all copies or substantial portions of the Software.
 
14
 
 
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
16
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
17
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
18
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
 
19
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 
20
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
21
OTHER DEALINGS IN THE SOFTWARE.
 
22
 
 
23
Except as contained in this notice, the name of The Open Group shall
 
24
not be used in advertising or otherwise to promote the sale, use or
 
25
other dealings in this Software without prior written authorization
 
26
from The Open Group.
 
27
 
 
28
*/
 
29
 
 
30
/* $XFree86: xc/programs/bdftopcf/bdftopcf.c,v 1.5 2001/12/14 20:00:39 dawes Exp $ */
 
31
 
 
32
#include <X11/X.h>
 
33
#include <X11/Xproto.h>
 
34
#include "fontmisc.h"
 
35
#include "fontstruct.h"
 
36
#include "fntfilio.h"
 
37
#include "fntfil.h"
 
38
#include "bdfint.h"
 
39
#include "pcf.h"
 
40
#include <stdio.h>
 
41
#include <X11/Xos.h>
 
42
 
 
43
int
 
44
main (int argc, char *argv[])
 
45
{
 
46
    FontRec font;
 
47
    FontFilePtr input, output;
 
48
    char    *input_name = 0, *output_name = 0;
 
49
    char    *program_name;
 
50
    int     bit, byte, glyph, scan;
 
51
 
 
52
    bzero(&font, sizeof(FontRec));
 
53
 
 
54
    FontDefaultFormat (&bit, &byte, &glyph, &scan);
 
55
    program_name = argv[0];
 
56
    argc--, argv++;
 
57
    while (argc-- > 0) {
 
58
        if (argv[0][0] == '-') {
 
59
            switch (argv[0][1]) {
 
60
            case 'p':
 
61
                switch (argv[0][2]) {
 
62
                case '1':
 
63
                case '2':
 
64
                case '4':
 
65
                case '8':
 
66
                    if (argv[0][3] != '\0')
 
67
                        goto usage;
 
68
                    glyph = argv[0][2] - '0';
 
69
                    break;
 
70
                default:
 
71
                    goto usage;
 
72
                }
 
73
                break;
 
74
 
 
75
            case 'u':
 
76
                switch (argv[0][2]) {
 
77
                case '1':
 
78
                case '2':
 
79
                case '4':
 
80
                    if (argv[0][3] != '\0')
 
81
                        goto usage;
 
82
                    scan = argv[0][2] - '0';
 
83
                    break;
 
84
                default:
 
85
                    goto usage;
 
86
                }
 
87
                break;
 
88
 
 
89
            case 'm':
 
90
                if (argv[0][2] != '\0')
 
91
                    goto usage;
 
92
                bit = MSBFirst;
 
93
                break;
 
94
 
 
95
            case 'l':
 
96
                if (argv[0][2] != '\0')
 
97
                    goto usage;
 
98
                bit = LSBFirst;
 
99
                break;
 
100
 
 
101
            case 'M':
 
102
                if (argv[0][2] != '\0')
 
103
                    goto usage;
 
104
                byte = MSBFirst;
 
105
                break;
 
106
 
 
107
            case 'L':
 
108
                if (argv[0][2] != '\0')
 
109
                    goto usage;
 
110
                byte = LSBFirst;
 
111
                break;
 
112
 
 
113
            case 't':   /* attempt to make terminal fonts if possible */
 
114
                if (argv[0][2] != '\0')
 
115
                    goto usage;
 
116
                break;
 
117
 
 
118
            case 'i':   /* inhibit ink metric computation */
 
119
                if (argv[0][2] != '\0')
 
120
                    goto usage;
 
121
                break;
 
122
            case 'o':
 
123
                if (argv[0][2])
 
124
                    output_name = argv[0] + 2;
 
125
                else
 
126
                {
 
127
                    if (!argv[1])
 
128
                        goto usage;
 
129
                    argv++;
 
130
                    argc--;
 
131
                    output_name = argv[0];
 
132
                }
 
133
                break;
 
134
            default:
 
135
                goto usage;
 
136
            }
 
137
        } else {
 
138
            if (input_name)
 
139
            {
 
140
        usage:
 
141
                fprintf(stderr,
 
142
        "usage: %s [-p#] [-u#] [-m] [-l] [-M] [-L] [-t] [-i] [-o pcf file] [bdf file]\n",
 
143
                        program_name);
 
144
                fprintf(stderr,
 
145
                        "       where # for -p is 1, 2, 4, or 8\n");
 
146
                fprintf(stderr,
 
147
                        "       and   # for -s is 1, 2, or 4\n");
 
148
                exit(1);
 
149
            }
 
150
            input_name = argv[0];
 
151
        }
 
152
        argv++;
 
153
    }
 
154
    if (input_name)
 
155
    {
 
156
        input = FontFileOpen (input_name);
 
157
        if (!input)
 
158
        {
 
159
            fprintf (stderr, "%s: can't open bdf source file %s\n",
 
160
                     program_name, input_name);
 
161
            exit (1);
 
162
        }
 
163
    }
 
164
    else
 
165
        input = FontFileOpenFd (0);
 
166
    if (bdfReadFont (&font, input, bit, byte, glyph, scan) != Successful)
 
167
    {
 
168
        fprintf (stderr, "%s: bdf input, %s, corrupt\n",
 
169
                 program_name, input_name);
 
170
        exit (1);
 
171
    }
 
172
    if (output_name)
 
173
    {
 
174
        output = FontFileOpenWrite (output_name);
 
175
        if (!output)
 
176
        {
 
177
            fprintf (stderr, "%s: can't open pcf sink file %s\n",
 
178
                     program_name, output_name);
 
179
            exit (1);
 
180
        }
 
181
    } 
 
182
    else
 
183
        output = FontFileOpenWriteFd (1);
 
184
    if (pcfWriteFont (&font, output) != Successful)
 
185
    {
 
186
        fprintf (stderr, "%s: can't write pcf file %s\n",
 
187
                 program_name, output_name ? output_name : "<stdout>");
 
188
        if (output_name)
 
189
            unlink (output_name);
 
190
        exit (1);
 
191
    }
 
192
    else
 
193
        FontFileClose (output);
 
194
    return (0);
 
195
}