~ubuntu-branches/ubuntu/vivid/ghostscript/vivid-security

« back to all changes in this revision

Viewing changes to base/gp_wgetv.c

  • Committer: Package Import Robot
  • Author(s): Till Kamppeter
  • Date: 2013-08-09 20:01:36 UTC
  • mfrom: (1.1.37)
  • Revision ID: package-import@ubuntu.com-20130809200136-amb6zrr7hnjb5jq9
Tags: 9.08~rc1~dfsg-0ubuntu1
* New upstream release
   - Ghostscript 9.08rc1.
   - We are using the system's liblcms2 and libopenjpeg now.
* debian/patches/020130401-852e545-pxl-xl-driver-produced-drawing-commands-without-setting-color-space.patch:
  Removed patch backported from upstream.
* debian/patches/ojdk-8007925+8007926.patch,
  debian/patches/ojdk-8007927.patch,
  debian/patches/ojdk-8007929.patch,
  debian/patches/ojdk-8009654.patch: Removed patches on build in liblcms2, we
  use the system's liblcms2 now.
* debian/patches/2001_docdir_fix_for_debian.patch: Manually updated to new
  upstream source code.
* debian/patches/2003_support_multiarch.patch: Refreshed with quilt.
* debian/control: Added build dependencies on liblcms2-dev and
  libopenjpeg-dev.
* debian/rules: Check for removed lcms2/ and openjpeg/ subdirectories in
  the repackaging check again, also set build options for shared liblcms2
  and libopenjpeg libraries.
* debian/rules: Makefile.in and configure.ac are in the root directory of
  the source now and do not need to get linked from base/. Also there is no
  gstoraster and gstopxl CUPS filter in the package any more and no
  "install-cups" make target any more.
* debian/control, debian/rules, debian/ghostscript-cups.install,
  debian/ghostscript-cups.ppd-updater: Removed the ghostscript-cups binary
  package. The files are now provided by cups-filters.
* debian/symbols.common: Updated for new upstream source. Applied patch
  which dpkg-gensymbols generated for debian/libgs9.symbols to this file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <stdlib.h>             /* for getenv */
22
22
#include <string.h>
23
23
#include "gscdefs.h"            /* for gs_productfamily and gs_revision and gs_serialnumber */
 
24
#include "gssprintf.h"          /* for gs_sprintf when GS_NO_UTF8=1 */
24
25
 
25
26
#if defined(__WIN32__) && !defined(METRO)
26
27
/*
28
29
 * Key = hkeyroot\\key, named value = name.
29
30
 * name, ptr, plen and return values are the same as in gp_getenv();
30
31
 */
31
 
#ifdef WINDOWS_NO_UNICODE
 
32
#ifdef GS_NO_UTF8
32
33
static int
33
34
gp_getenv_registry(HKEY hkeyroot, const char *key, const char *name,
34
35
    char *ptr, int *plen)
58
59
    }
59
60
    return 1;   /* not found */
60
61
}
61
 
#else        /* ifdef WINDOWS_NO_UNICODE */
 
62
#else        /* ifdef GS_NO_UTF8 */
62
63
int
63
64
gp_getenv_registry(HKEY hkeyroot, const wchar_t *key, const char *name,
64
65
    char *ptr, int *plen)
135
136
    free(wname);
136
137
    return 1;                           /* environment variable does not exist */
137
138
}
138
 
#endif        /* ifdef WINDOWS_NO_UNICODE */
 
139
#endif        /* ifdef GS_NO_UTF8 */
139
140
#endif    /* ifdef __WIN32__ */
140
141
 
141
142
/* ------ Environment variables ------ */
144
145
int
145
146
gp_getenv(const char *name, char *ptr, int *plen)
146
147
{
 
148
#ifdef GS_NO_UTF8
147
149
    const char *str = getenv(name);
148
150
 
149
151
    if (str) {
159
161
        *plen = len + 1;
160
162
        return -1;
161
163
    }
 
164
#else
 
165
    const wchar_t *str = _wgetenv(name);
 
166
 
 
167
    if (str) {
 
168
        /* wchar_to_utf8 returns INCLUDING terminator */
 
169
        int len = wchar_to_utf8(NULL, str);
 
170
 
 
171
        if (len <= *plen) {
 
172
            /* string fits */
 
173
            *plen = wchar_to_utf8(ptr, str);
 
174
            return 0;
 
175
        }
 
176
        /* string doesn't fit */
 
177
        *plen = len;
 
178
        return -1;
 
179
    }
 
180
#endif
162
181
    /* environment variable was not found */
163
182
 
164
183
#if defined(__WIN32__) && !defined(METRO)
177
196
              && ((HIWORD(version) & 0x4000) == 0))) {
178
197
            /* not Win32s */
179
198
            int code;
180
 
#ifdef WINDOWS_NO_UNICODE
 
199
#ifdef GS_NO_UTF8
181
200
            char key[256];
182
201
            char dotversion[16];
183
202
 
184
 
            sprintf(dotversion, "%d.%02d", (int)(gs_revision / 100),
 
203
            gs_sprintf(dotversion, "%d.%02d", (int)(gs_revision / 100),
185
204
                    (int)(gs_revision % 100));
186
 
            sprintf(key, "Software\\%s\\%s", gs_productfamily, dotversion);
 
205
            gs_sprintf(key, "Software\\%s\\%s", gs_productfamily, dotversion);
187
206
#else
188
207
            wchar_t key[256];
189
208
            wchar_t dotversion[16];
221
240
    byte buf[SERIALNUMBER_BUFSIZE];
222
241
    int buflen = SERIALNUMBER_BUFSIZE;
223
242
    int code, i;
224
 
#ifdef WINDOWS_NO_UNICODE
 
243
#ifdef GS_NO_UTF8
225
244
    char key[256];
226
245
 
227
 
    sprintf(key, "Software\\Microsoft\\MSLicensing\\HardwareID");
228
 
#else        /* WINDOWS_NO_UNICODE */
 
246
    gs_sprintf(key, "Software\\Microsoft\\MSLicensing\\HardwareID");
 
247
#else        /* GS_NO_UTF8 */
229
248
    wchar_t key[256];
230
249
 
231
250
    wsprintfW(key, L"Software\\Microsoft\\MSLicensing\\HardwareID");
232
 
#endif        /* WINDOWS_NO_UNICODE */
 
251
#endif        /* GS_NO_UTF8 */
233
252
    code = gp_getenv_registry(HKEY_LOCAL_MACHINE, key, "ClientHWID", (char *)buf, &buflen);
234
253
    if ( code != 0 )
235
254
        return (int)(gs_serialnumber);  /* error - just return the default */