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
6
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=604448
8
src/vncdisplay.c | 67 ++++++++++++++++++++++++++++++-----------------------
9
1 files changed, 38 insertions(+), 29 deletions(-)
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);
19
-static int vnc_display_best_path(char *buf,
21
- const char *basedir,
22
- const char *basefile,
25
+static char* vnc_display_best_path(const char *basedir,
26
+ const char *basefile,
32
for (i = 0 ; i < ndirs ; i++) {
34
- snprintf(buf, buflen-1, "%s/%s/%s", dirs[i], basedir, basefile);
35
- buf[buflen-1] = '\0';
36
- if (stat(buf, &sb) == 0)
38
+ path = g_strdup_printf ("%s/%s/%s", dirs[i], basedir, basefile);
39
+ if (stat(path, &sb) == 0)
47
static int vnc_display_set_x509_credential(VncDisplay *obj, const char *name)
49
- char file[PATH_MAX];
50
- char sysdir[PATH_MAX];
51
+ gboolean ret = FALSE;
55
- char userdir[PATH_MAX];
58
char *dirs[] = { sysdir, userdir };
60
char *dirs[] = { sysdir };
63
- strncpy(sysdir, SYSCONFDIR "/pki", PATH_MAX-1);
64
- sysdir[PATH_MAX-1] = '\0';
67
if (!(pw = getpwuid(getuid())))
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);
75
- if (vnc_display_best_path(file, PATH_MAX, "CA", "cacert.pem",
76
- dirs, sizeof(dirs)/sizeof(dirs[0])) < 0)
78
+ sysdir = g_strdup_printf("%s/pki", SYSCONFDIR);
80
+ if ((file = vnc_display_best_path("CA", "cacert.pem", dirs,
81
+ sizeof(dirs)/sizeof(dirs[0]))) == NULL) {
85
gvnc_set_credential_x509_cacert(obj->priv->gvnc, file);
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);
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)
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);
120
gboolean vnc_display_set_credential(VncDisplay *obj, int type, const gchar *data)