about summary refs log tree commit diff stats
path: root/src/config
diff options
context:
space:
mode:
authorPeter Vilim <peterlvilim@users.noreply.github.com>2015-01-07 21:37:35 -0600
committerPeter Vilim <peterlvilim@users.noreply.github.com>2015-01-07 21:37:35 -0600
commit0cb548683c906eb7e48ddfccde4b95f671dea5fc (patch)
tree0dce7c2d92fd90111e4cf0beb0b5d232094b2772 /src/config
parentb298994ce755d4ddc0c7de882c989e58806c212d (diff)
downloadprofani-tty-0cb548683c906eb7e48ddfccde4b95f671dea5fc.tar.gz
fgets: buffer size
Diffstat (limited to 'src/config')
-rw-r--r--src/config/accounts.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/config/accounts.c b/src/config/accounts.c
index 784651ad..2e7092a5 100644
--- a/src/config/accounts.c
+++ b/src/config/accounts.c
@@ -230,9 +230,12 @@ accounts_get_account(const char * const name)
         // Evaluate as shell command to retrieve password
         if (eval_password != NULL) {
             FILE *stream = popen(eval_password, "r");
-            // Limit to 100 bytes to prevent overflows in the case of a poorly chosen command
-            password = g_malloc(100);
-            password = fgets(password, 100, stream);
+            // Limit to READ_BUF_SIZE bytes to prevent overflows in the case of a poorly chosen command
+            password = g_malloc(READ_BUF_SIZE);
+            gchar *result = fgets(password, READ_BUF_SIZE, stream);
+            if (result != NULL) {
+                password = result;
+            }
         }
         gboolean enabled = g_key_file_get_boolean(accounts, name, "enabled", NULL);