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

« back to all changes in this revision

Viewing changes to unix/xc/config/pswrap/pswstring.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
 *  pswstring.c
 
3
 *
 
4
 * (c) Copyright 1988-1994 Adobe Systems Incorporated.
 
5
 * All rights reserved.
 
6
 * 
 
7
 * Permission to use, copy, modify, distribute, and sublicense this software
 
8
 * and its documentation for any purpose and without fee is hereby granted,
 
9
 * provided that the above copyright notices appear in all copies and that
 
10
 * both those copyright notices and this permission notice appear in
 
11
 * supporting documentation and that the name of Adobe Systems Incorporated
 
12
 * not be used in advertising or publicity pertaining to distribution of the
 
13
 * software without specific, written prior permission.  No trademark license
 
14
 * to use the Adobe trademarks is hereby granted.  If the Adobe trademark
 
15
 * "Display PostScript"(tm) is used to describe this software, its
 
16
 * functionality or for any other purpose, such use shall be limited to a
 
17
 * statement that this software works in conjunction with the Display
 
18
 * PostScript system.  Proper trademark attribution to reflect Adobe's
 
19
 * ownership of the trademark shall be given whenever any such reference to
 
20
 * the Display PostScript system is made.
 
21
 * 
 
22
 * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR
 
23
 * ANY PURPOSE.  IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
 
24
 * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
 
25
 * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
26
 * NON- INFRINGEMENT OF THIRD PARTY RIGHTS.  IN NO EVENT SHALL ADOBE BE LIABLE
 
27
 * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL
 
28
 * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT,
 
29
 * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN
 
30
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.  ADOBE WILL NOT
 
31
 * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE.
 
32
 * 
 
33
 * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems
 
34
 * Incorporated which may be registered in certain jurisdictions
 
35
 * 
 
36
 * Author:  Adobe Systems Incorporated
 
37
 */
 
38
/* $XFree86: xc/config/pswrap/pswstring.c,v 1.3 2000/09/26 15:56:28 tsi Exp $ */
 
39
 
 
40
#include <stdio.h>
 
41
#include <ctype.h>
 
42
#include <string.h>
 
43
 
 
44
#include "pswpriv.h"
 
45
#include "psw.h"
 
46
 
 
47
#define outfil stdout
 
48
#define MAX_PER_LINE 16
 
49
 
 
50
int PSWStringLength(char *s)
 
51
{
 
52
    register char *c = s;
 
53
    register int len = 0;
 
54
 
 
55
    while (*c != '\0') {        /* skip \\ and \ooo */
 
56
        if (*c++ == '\\') {
 
57
            if (*c++ != '\\') c += 2;
 
58
        }
 
59
        len++;
 
60
    }
 
61
    return (len);
 
62
}
 
63
 
 
64
void PSWOutputStringChars(char *s)
 
65
{
 
66
    register char *c = s;
 
67
    register char b;
 
68
    register int perline = 0;
 
69
    
 
70
    while (*c != '\0') {
 
71
    putc('\'',outfil);
 
72
    switch (b = *c++) {
 
73
            case '\\':
 
74
                putc('\\',outfil);
 
75
                fputc(b = *c++,outfil);
 
76
                if (b != '\\') {putc(*c++,outfil);putc(*c++,outfil);}
 
77
                break;
 
78
            case '\'':
 
79
                fprintf(outfil,"\\'");
 
80
                break;
 
81
            case '\"':
 
82
                fprintf(outfil,"\\\"");
 
83
                break;
 
84
            case '\b':
 
85
                fprintf(outfil,"\\b");
 
86
                break;
 
87
            case '\f':
 
88
                fprintf(outfil,"\\f");
 
89
                break;
 
90
/* avoid funny interpretations of \n, \r by MPW */
 
91
            case '\012':
 
92
                fprintf(outfil,"\\012"); perline++;
 
93
                break;
 
94
            case '\015':
 
95
                fprintf(outfil,"\\015"); perline++;
 
96
                break;
 
97
            case '\t':
 
98
                fprintf(outfil,"\\t");
 
99
                break;
 
100
            default:
 
101
                putc(b,outfil); perline--;
 
102
                break;
 
103
        }
 
104
        putc('\'',outfil);
 
105
        if (*c != '\0') {
 
106
            if (++perline >= MAX_PER_LINE) {
 
107
                fprintf(outfil,",\n     ");
 
108
                outlineno++;
 
109
            }
 
110
            else {putc(',',outfil);}
 
111
            perline %= MAX_PER_LINE;
 
112
        }
 
113
    }
 
114
}
 
115
 
 
116
 
 
117
int PSWHexStringLength(char *s)
 
118
{
 
119
    return ((int) (strlen(s)+1)/2);
 
120
}
 
121
 
 
122
void PSWOutputHexStringChars(register char *s)
 
123
{
 
124
    register int perline = 0;
 
125
    char tmp[3];
 
126
 
 
127
    tmp[2] ='\0';
 
128
    while ((tmp[0] = *s++)!= '\0') {
 
129
        tmp[1] = *s ? *s++ : '\0';
 
130
        fprintf(outfil,"0x%s",tmp);
 
131
        if (*s != '\0') {
 
132
            if (++perline >= MAX_PER_LINE) {
 
133
                fprintf(outfil,",\n     ");
 
134
                outlineno++;
 
135
            }
 
136
            else {putc(',',outfil);}
 
137
            perline %= MAX_PER_LINE;
 
138
        }
 
139
    } /* while */
 
140
}