2008-07-02 Dan Williams <dcbw@redhat.com>

* properties/auth-helpers.c
		- (tls_default_filter): read more of the certificate/key file to look
			for the known certificate or key tags, not just 1024 bytes



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3801 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams
2008-07-02 20:36:39 +00:00
parent a8a0c113a7
commit f33b102a97
2 changed files with 20 additions and 12 deletions

View File

@@ -1,3 +1,9 @@
2008-07-02 Dan Williams <dcbw@redhat.com>
* properties/auth-helpers.c
- (tls_default_filter): read more of the certificate/key file to look
for the known certificate or key tags, not just 1024 bytes
2008-06-30 Dan Williams <dcbw@redhat.com> 2008-06-30 Dan Williams <dcbw@redhat.com>
* properties/auth-helpers.c * properties/auth-helpers.c

View File

@@ -458,11 +458,10 @@ static gboolean
tls_default_filter (const GtkFileFilterInfo *filter_info, gpointer data) tls_default_filter (const GtkFileFilterInfo *filter_info, gpointer data)
{ {
int fd; int fd;
unsigned char buffer[1024]; char *contents = NULL, *p, *ext;
ssize_t bytes_read; gsize bytes_read = 0;
gboolean show = FALSE; gboolean show = FALSE;
char *p; struct stat statbuf;
char *ext;
if (!filter_info->filename) if (!filter_info->filename)
return FALSE; return FALSE;
@@ -480,33 +479,36 @@ tls_default_filter (const GtkFileFilterInfo *filter_info, gpointer data)
} }
g_free (ext); g_free (ext);
fd = open (filter_info->filename, O_RDONLY); /* Ignore files that are really large */
if (fd < 0) if (!stat (filter_info->filename, &statbuf)) {
if (statbuf.st_size > 500000)
return FALSE;
}
if (!g_file_get_contents (filter_info->filename, &contents, &bytes_read, NULL))
return FALSE; return FALSE;
bytes_read = read (fd, buffer, sizeof (buffer) - 1);
if (bytes_read < 400) /* needs to be lower? */ if (bytes_read < 400) /* needs to be lower? */
goto out; goto out;
buffer[bytes_read] = '\0';
/* Check for PEM signatures */ /* Check for PEM signatures */
if (find_tag (pem_rsa_key_begin, (const char *) buffer, bytes_read)) { if (find_tag (pem_rsa_key_begin, (const char *) contents, bytes_read)) {
show = TRUE; show = TRUE;
goto out; goto out;
} }
if (find_tag (pem_dsa_key_begin, (const char *) buffer, bytes_read)) { if (find_tag (pem_dsa_key_begin, (const char *) contents, bytes_read)) {
show = TRUE; show = TRUE;
goto out; goto out;
} }
if (find_tag (pem_cert_begin, (const char *) buffer, bytes_read)) { if (find_tag (pem_cert_begin, (const char *) contents, bytes_read)) {
show = TRUE; show = TRUE;
goto out; goto out;
} }
out: out:
close (fd); g_free (contents);
return show; return show;
} }