aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2022-10-12 18:20:27 -0700
committerGerald Combs <gerald@wireshark.org>2022-10-13 16:32:43 +0000
commitf10538a1021e709f9024ac25f3ad3354de58fa01 (patch)
treef2257e44cf433e31c0ee468dc12757172f8f3a9e
parentb484c4181118369825ffb4333ce7442ea1cf01aa (diff)
falcodump: Fix our credential and config file parsing.
-rw-r--r--extcap/falcodump.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/extcap/falcodump.cpp b/extcap/falcodump.cpp
index 5bab48b5b9..6127e84f06 100644
--- a/extcap/falcodump.cpp
+++ b/extcap/falcodump.cpp
@@ -122,11 +122,11 @@ struct plugin_configuration {
// Read a line without trailing (CR)LF. Returns -1 on failure. Copied from addr_resolv.c.
// XXX Use g_file_get_contents or GMappedFile instead?
-static size_t
+static int
fgetline(char *buf, int size, FILE *fp)
{
if (fgets(buf, size, fp)) {
- size_t len = (int)strcspn(buf, "\r\n");
+ int len = (int)strcspn(buf, "\r\n");
buf[len] = '\0';
return len;
}
@@ -143,15 +143,14 @@ void print_cloudtrail_aws_profile_config(int arg_num, const char *display, const
// Look in files as specified in https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html
char *cred_path = g_strdup(g_getenv("AWS_SHARED_CREDENTIALS_FILE"));
if (cred_path == NULL) {
- cred_path = g_build_filename(g_get_home_dir(), ".aws/credentials", (gchar *)NULL);
+ cred_path = g_build_filename(g_get_home_dir(), ".aws", "credentials", (gchar *)NULL);
}
aws_fp = ws_fopen(cred_path, "r");
g_free(cred_path);
if (aws_fp != NULL) {
-
- while (fgetline(buf, sizeof(buf), aws_fp) > 0) {
+ while (fgetline(buf, sizeof(buf), aws_fp) >= 0) {
if (sscanf(buf, "[%2047[^]]s]", profile) == 1) {
if (strcmp(profile, "default") == 0) {
continue;
@@ -164,15 +163,14 @@ void print_cloudtrail_aws_profile_config(int arg_num, const char *display, const
char *conf_path = g_strdup(g_getenv("AWS_CONFIG_FILE"));
if (conf_path == NULL) {
- conf_path = g_build_filename(g_get_home_dir(), ".aws/config", (gchar *)NULL);
+ conf_path = g_build_filename(g_get_home_dir(), ".aws", "config", (gchar *)NULL);
}
aws_fp = ws_fopen(conf_path, "r");
g_free(conf_path);
if (aws_fp != NULL) {
-
- while (fgetline(buf, sizeof(buf), aws_fp) > 0) {
+ while (fgetline(buf, sizeof(buf), aws_fp) >= 0) {
if (sscanf(buf, "[profile %2047[^]]s]", profile) == 1) {
if (strcmp(profile, "default") == 0) {
continue;