diff options
author | Jeffrey Stedfast <fejj@helixcode.com> | 2000-11-04 06:56:19 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2000-11-04 06:56:19 +0800 |
commit | 3c3b702d1f80cb05db741ba65bfd27d82d5d7104 (patch) | |
tree | 34ab75d7e76e73e3fb89d5d09a951c8f71a16bf8 /composer | |
parent | ebf0a583f706bdd74b13a2c4c725a239daab939e (diff) | |
download | gsoc2013-evolution-3c3b702d1f80cb05db741ba65bfd27d82d5d7104.tar gsoc2013-evolution-3c3b702d1f80cb05db741ba65bfd27d82d5d7104.tar.gz gsoc2013-evolution-3c3b702d1f80cb05db741ba65bfd27d82d5d7104.tar.bz2 gsoc2013-evolution-3c3b702d1f80cb05db741ba65bfd27d82d5d7104.tar.lz gsoc2013-evolution-3c3b702d1f80cb05db741ba65bfd27d82d5d7104.tar.xz gsoc2013-evolution-3c3b702d1f80cb05db741ba65bfd27d82d5d7104.tar.zst gsoc2013-evolution-3c3b702d1f80cb05db741ba65bfd27d82d5d7104.zip |
Don't allow attaching anything but regular files.
2000-11-03 Jeffrey Stedfast <fejj@helixcode.com>
* e-msg-composer-attachment.c (e_msg_composer_attachment_new):
Don't allow attaching anything but regular files.
svn path=/trunk/; revision=6384
Diffstat (limited to 'composer')
-rw-r--r-- | composer/ChangeLog | 5 | ||||
-rw-r--r-- | composer/e-msg-composer-attachment.c | 35 |
2 files changed, 25 insertions, 15 deletions
diff --git a/composer/ChangeLog b/composer/ChangeLog index 6115de5f12..c3a8c4bd57 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,8 @@ +2000-11-03 Jeffrey Stedfast <fejj@helixcode.com> + + * e-msg-composer-attachment.c (e_msg_composer_attachment_new): + Don't allow attaching anything but regular files. + 2000-11-03 Federico Mena Quintero <federico@helixcode.com> * Makefile.am: Clean the idl-generated files properly. diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c index 58484d5f98..bd9ae43b3b 100644 --- a/composer/e-msg-composer-attachment.c +++ b/composer/e-msg-composer-attachment.c @@ -170,42 +170,47 @@ e_msg_composer_attachment_new (const gchar *file_name) EMsgComposerAttachment *new; CamelMimePart *part; CamelDataWrapper *wrapper; - CamelStream *data; + CamelStream *stream; struct stat statbuf; gchar *mime_type; - + g_return_val_if_fail (file_name != NULL, NULL); - - data = camel_stream_fs_new_with_name (file_name, O_RDONLY, 0); - if (!data) + + if (stat (file_name, &statbuf) < 0) + return; + + /* return if it's not a regular file */ + if (!S_ISREG (statbuf.st_dev)) + return; + + stream = camel_stream_fs_new_with_name (file_name, O_RDONLY, 0); + if (!stream) return NULL; wrapper = camel_data_wrapper_new (); - camel_data_wrapper_construct_from_stream (wrapper, data); - camel_object_unref (CAMEL_OBJECT (data)); + camel_data_wrapper_construct_from_stream (wrapper, stream); + camel_object_unref (CAMEL_OBJECT (stream)); mime_type = get_mime_type (file_name); if (mime_type) { camel_data_wrapper_set_mime_type (wrapper, mime_type); g_free (mime_type); } else camel_data_wrapper_set_mime_type (wrapper, "application/octet-stream"); - + part = camel_mime_part_new (); camel_medium_set_content_object (CAMEL_MEDIUM (part), wrapper); camel_object_unref (CAMEL_OBJECT (wrapper)); - + camel_mime_part_set_disposition (part, "attachment"); if (strchr (file_name, '/')) camel_mime_part_set_filename (part, strrchr (file_name, '/') + 1); else camel_mime_part_set_filename (part, file_name); - + new = e_msg_composer_attachment_new_from_mime_part (part); - if (stat (file_name, &statbuf) < 0) - new->size = 0; - else - new->size = statbuf.st_size; + + new->size = statbuf.st_size; new->guessed_type = TRUE; - + return new; } |