~ubuntu-branches/ubuntu/vivid/gtk-vnc/vivid

« back to all changes in this revision

Viewing changes to debian/patches/0004-Don-t-use-PATH_MAX.patch

  • Committer: Bazaar Package Importer
  • Author(s): Guido Günther
  • Date: 2010-07-16 17:55:31 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20100716175531-vnolppaqgmo3rqij
Tags: 0.4.1-1
* [2703df5] Imported Upstream version 0.4.1
* [5a5910e] Drop patches applied upstream 
      0001-say-disconnected-from-server-only-once-connected.patch
      0002-remove-WERROR_CFLAGS.patch
      0004-Don-t-use-PATH_MAX.patch
      0005-Drop-space-after-Wl-in-libgtk_vnc_1_0_la_LDFLAGS.patch
      0006-Add-Wl-since-no-undefined-is-a-linker-option.patch
      0007-Explicitly-link-against-X11-libs-for-XkbGetKeyboard.patch
      0008-Add-missing-symbols.patch
      0009-Fix-missing-intialisation-of-sysdir-and-uderdir.patch
* [e3ed1d0] No need to run autoreconf anymore
* [1529b9a] No static libs built
* [15068ef] Update symbols file with new symbols
* [337c397] Bump standards version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From: Emilio Pozuelo Monfort <pochu@debian.org>
2
 
Date: Sun, 28 Feb 2010 17:30:11 +0100
3
 
Subject: [PATCH] Don't use PATH_MAX
4
 
 
5
 
Closes: #561004
6
 
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=604448
7
 
---
8
 
 src/vncdisplay.c |   67 ++++++++++++++++++++++++++++++-----------------------
9
 
 1 files changed, 38 insertions(+), 29 deletions(-)
10
 
 
11
 
diff --git a/src/vncdisplay.c b/src/vncdisplay.c
12
 
index f779a63..98c2795 100644
13
 
--- a/src/vncdisplay.c
14
 
+++ b/src/vncdisplay.c
15
 
@@ -1998,67 +1998,76 @@ static void vnc_display_init(VncDisplay *display)
16
 
        priv->gvnc = gvnc_new(&vnc_display_ops, obj);
17
 
 }
18
 
 
19
 
-static int vnc_display_best_path(char *buf,
20
 
-                                int buflen,
21
 
-                                const char *basedir,
22
 
-                                const char *basefile,
23
 
-                                char **dirs,
24
 
-                                unsigned int ndirs)
25
 
+static char* vnc_display_best_path(const char *basedir,
26
 
+                           const char *basefile,
27
 
+                           char **dirs,
28
 
+                           unsigned int ndirs)
29
 
 {
30
 
        unsigned int i;
31
 
+       char *path;
32
 
        for (i = 0 ; i < ndirs ; i++) {
33
 
                struct stat sb;
34
 
-               snprintf(buf, buflen-1, "%s/%s/%s", dirs[i], basedir, basefile);
35
 
-               buf[buflen-1] = '\0';
36
 
-               if (stat(buf, &sb) == 0)
37
 
-                       return 0;
38
 
+               path = g_strdup_printf ("%s/%s/%s", dirs[i], basedir, basefile);
39
 
+               if (stat(path, &sb) == 0)
40
 
+                       return path;
41
 
+               g_free (path);
42
 
        }
43
 
-       return -1;
44
 
+       return NULL;
45
 
 }
46
 
 
47
 
 static int vnc_display_set_x509_credential(VncDisplay *obj, const char *name)
48
 
 {
49
 
-       char file[PATH_MAX];
50
 
-       char sysdir[PATH_MAX];
51
 
+       gboolean ret = FALSE;
52
 
+       char *file;
53
 
+       char *sysdir;
54
 
 #ifndef WIN32
55
 
-       char userdir[PATH_MAX];
56
 
+       char *userdir;
57
 
        struct passwd *pw;
58
 
        char *dirs[] = { sysdir, userdir };
59
 
 #else
60
 
        char *dirs[] = { sysdir };
61
 
 #endif
62
 
 
63
 
-       strncpy(sysdir, SYSCONFDIR "/pki", PATH_MAX-1);
64
 
-       sysdir[PATH_MAX-1] = '\0';
65
 
-
66
 
 #ifndef WIN32
67
 
        if (!(pw = getpwuid(getuid())))
68
 
                return TRUE;
69
 
 
70
 
-       snprintf(userdir, PATH_MAX-1, "%s/.pki", pw->pw_dir);
71
 
-       userdir[PATH_MAX-1] = '\0';
72
 
+       userdir = g_strdup_printf("%s/.pki", pw->pw_dir);
73
 
 #endif
74
 
 
75
 
-       if (vnc_display_best_path(file, PATH_MAX, "CA", "cacert.pem",
76
 
-                                 dirs, sizeof(dirs)/sizeof(dirs[0])) < 0)
77
 
-               return TRUE;
78
 
+       sysdir = g_strdup_printf("%s/pki", SYSCONFDIR);
79
 
+
80
 
+       if ((file = vnc_display_best_path("CA", "cacert.pem", dirs,
81
 
+                                 sizeof(dirs)/sizeof(dirs[0]))) == NULL) {
82
 
+               ret = TRUE;
83
 
+               goto ret;
84
 
+       }
85
 
        gvnc_set_credential_x509_cacert(obj->priv->gvnc, file);
86
 
+       g_free (file);
87
 
 
88
 
        /* Don't mind failures of CRL */
89
 
-       if (vnc_display_best_path(file, PATH_MAX, "CA", "cacrl.pem",
90
 
-                                 dirs, sizeof(dirs)/sizeof(dirs[0])) == 0)
91
 
+       if ((file = vnc_display_best_path("CA", "cacrl.pem", dirs,
92
 
+                                 sizeof(dirs)/sizeof(dirs[0]))) != NULL)
93
 
                gvnc_set_credential_x509_cacert(obj->priv->gvnc, file);
94
 
+       g_free (file);
95
 
 
96
 
        /* Set client key & cert if we have them. Server will reject auth
97
 
         * if it decides it requires them*/
98
 
-       if (vnc_display_best_path(file, PATH_MAX, name, "private/clientkey.pem",
99
 
-                                 dirs, sizeof(dirs)/sizeof(dirs[0])) == 0)
100
 
+       if ((file = vnc_display_best_path(name, "private/clientkey.pem", dirs,
101
 
+                                 sizeof(dirs)/sizeof(dirs[0]))) != NULL)
102
 
                gvnc_set_credential_x509_key(obj->priv->gvnc, file);
103
 
-       if (vnc_display_best_path(file, PATH_MAX, name, "clientcert.pem",
104
 
-                                 dirs, sizeof(dirs)/sizeof(dirs[0])) == 0)
105
 
+       g_free (file);
106
 
+       if ((file = vnc_display_best_path(name, "clientcert.pem", dirs,
107
 
+                                 sizeof(dirs)/sizeof(dirs[0]))) != NULL)
108
 
                gvnc_set_credential_x509_cert(obj->priv->gvnc, file);
109
 
+       g_free (file);
110
 
 
111
 
-       return FALSE;
112
 
+     ret:
113
 
+#ifndef WIN32
114
 
+       g_free (userdir);
115
 
+#endif
116
 
+       g_free (sysdir);
117
 
+       return ret;
118
 
 }
119
 
 
120
 
 gboolean vnc_display_set_credential(VncDisplay *obj, int type, const gchar *data)