summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mail-client/mhng/files/mhng-0.0.2-fgets_return.patch')
-rw-r--r--mail-client/mhng/files/mhng-0.0.2-fgets_return.patch37
1 files changed, 37 insertions, 0 deletions
diff --git a/mail-client/mhng/files/mhng-0.0.2-fgets_return.patch b/mail-client/mhng/files/mhng-0.0.2-fgets_return.patch
new file mode 100644
index 0000000..d1b4d8c
--- /dev/null
+++ b/mail-client/mhng/files/mhng-0.0.2-fgets_return.patch
@@ -0,0 +1,37 @@
+commit d1d5f1c46aebf480af7c46d64b3fc0f75814946d
+Author: Palmer Dabbelt <palmer@dabbelt.com>
+Date: Fri Dec 5 15:47:25 2014 -0800
+
+ Check that the username/password files aren't empty
+
+ This would have caused a bit of undefined behavior due to some
+ uninitialized stack buffers.
+
+diff --git a/src/libmhng/mailbox.c++ b/src/libmhng/mailbox.c++
+index a21f9ab..794a74b 100644
+--- a/src/libmhng/mailbox.c++
++++ b/src/libmhng/mailbox.c++
+@@ -195,7 +195,10 @@ std::string mailbox::username(void) const
+ }
+
+ char line[BUFFER_SIZE];
+- fgets(line, BUFFER_SIZE, file);
++ if (fgets(line, BUFFER_SIZE, file) == NULL) {
++ fprintf(stderr, "Empty username file\n");
++ abort();
++ }
+ while (isspace(line[strlen(line)-1]))
+ line[strlen(line)-1] = '\0';
+
+@@ -218,7 +221,10 @@ std::string mailbox::password(void) const
+ }
+
+ char line[BUFFER_SIZE];
+- fgets(line, BUFFER_SIZE, file);
++ if (fgets(line, BUFFER_SIZE, file) == NULL) {
++ fprintf(stderr, "Empty password file\n");
++ abort();
++ }
+ while (isspace(line[strlen(line)-1]))
+ line[strlen(line)-1] = '\0';
+