diff --git a/mfshell/commands/changes.c b/mfshell/commands/changes.c index 97101a1..ce93159 100644 --- a/mfshell/commands/changes.c +++ b/mfshell/commands/changes.c @@ -38,6 +38,11 @@ int mfshell_cmd_changes(mfshell * mfshell, int argc, char *const argv[]) if (mfshell == NULL) return -1; + if (mfshell->conn == NULL) { + fprintf(stderr, "conn is NULL\n"); + return -1; + } + switch (argc) { case 1: revision = 0; @@ -54,6 +59,11 @@ int mfshell_cmd_changes(mfshell * mfshell, int argc, char *const argv[]) retval = mfconn_api_device_get_changes(mfshell->conn, revision, &changes); mfconn_update_secret_key(mfshell->conn); + if (retval != 0) { + fprintf(stderr, "mfconn_api_device_get_changes failed\n"); + return -1; + } + for (i = 0; changes[i].change != MFCONN_DEVICE_CHANGE_END; i++) { switch (changes[i].change) { case MFCONN_DEVICE_CHANGE_DELETED_FOLDER: diff --git a/mfshell/commands/chdir.c b/mfshell/commands/chdir.c index 10fc157..34dbbd1 100644 --- a/mfshell/commands/chdir.c +++ b/mfshell/commands/chdir.c @@ -77,9 +77,18 @@ int mfshell_cmd_chdir(mfshell * mfshell, int argc, char *const argv[]) folder_set_key(folder_new, NULL); retval = 0; } else { + if (mfshell->conn == NULL) { + fprintf(stderr, "conn is NULL\n"); + return -1; + } retval = mfconn_api_folder_get_info(mfshell->conn, folder_new, (char *)folderkey); mfconn_update_secret_key(mfshell->conn); + + if (retval != 0) { + fprintf(stderr, "mfconn_api_folder_get_info failed\n"); + return -1; + } } if (retval == 0) { diff --git a/mfshell/commands/file.c b/mfshell/commands/file.c index d57318e..989279b 100644 --- a/mfshell/commands/file.c +++ b/mfshell/commands/file.c @@ -38,6 +38,11 @@ int mfshell_cmd_file(mfshell * mfshell, int argc, char *const argv[]) if (mfshell == NULL) return -1; + if (mfshell->conn == NULL) { + fprintf(stderr, "conn is NULL\n"); + return -1; + } + if (argc != 2) { fprintf(stderr, "Invalid number of arguments\n"); return -1; @@ -55,11 +60,13 @@ int mfshell_cmd_file(mfshell * mfshell, int argc, char *const argv[]) file = file_alloc(); retval = mfconn_api_file_get_info(mfshell->conn, file, (char *)quickkey); - if (retval != 0) { - fprintf(stderr, "api call unsuccessful\n"); - } mfconn_update_secret_key(mfshell->conn); + if (retval != 0) { + fprintf(stderr, "mfconn_api_file_get_info failed\n"); + return -1; + } + quickkey = file_get_key(file); name = file_get_name(file); hash = file_get_hash(file); diff --git a/mfshell/commands/folder.c b/mfshell/commands/folder.c index 17aced2..764d716 100644 --- a/mfshell/commands/folder.c +++ b/mfshell/commands/folder.c @@ -52,6 +52,11 @@ int mfshell_cmd_folder(mfshell * mfshell, int argc, char *const argv[]) return -1; } + if (mfshell->conn == NULL) { + fprintf(stderr, "conn is NULL\n"); + return -1; + } + switch (argc) { case 1: folderkey = NULL; diff --git a/mfshell/commands/get.c b/mfshell/commands/get.c index 408c388..119a1ec 100644 --- a/mfshell/commands/get.c +++ b/mfshell/commands/get.c @@ -42,6 +42,11 @@ int mfshell_cmd_get(mfshell * mfshell, int argc, char *const argv[]) if (mfshell == NULL) return -1; + if (mfshell->conn == NULL) { + fprintf(stderr, "conn is NULL\n"); + return -1; + } + if (argc != 2) { fprintf(stderr, "Invalid number of arguments\n"); return -1; diff --git a/mfshell/commands/links.c b/mfshell/commands/links.c index a32ec17..1bb571c 100644 --- a/mfshell/commands/links.c +++ b/mfshell/commands/links.c @@ -39,6 +39,11 @@ int mfshell_cmd_links(mfshell * mfshell, int argc, char *const argv[]) if (mfshell == NULL) return -1; + if (mfshell->conn == NULL) { + fprintf(stderr, "conn is NULL\n"); + return -1; + } + if (argc != 2) { fprintf(stderr, "Invalid number of arguments\n"); return -1; diff --git a/mfshell/commands/list.c b/mfshell/commands/list.c index b9c75fa..c917df2 100644 --- a/mfshell/commands/list.c +++ b/mfshell/commands/list.c @@ -38,6 +38,11 @@ int mfshell_cmd_list(mfshell * mfshell, int argc, char *const argv[]) if (mfshell == NULL) return -1; + if (mfshell->conn == NULL) { + fprintf(stderr, "conn is NULL\n"); + return -1; + } + if (argc != 1) { fprintf(stderr, "Invalid number of arguments\n"); return -1; @@ -50,6 +55,10 @@ int mfshell_cmd_list(mfshell * mfshell, int argc, char *const argv[]) &folder_result, NULL); mfconn_update_secret_key(mfshell->conn); + if (folder_result == NULL) { + return -1; + } + for (i = 0; folder_result[i] != NULL; i++) { printf("%s %s\n", folder_get_name(folder_result[i]), folder_get_key(folder_result[i])); diff --git a/mfshell/commands/mkdir.c b/mfshell/commands/mkdir.c index ba74bd1..07266f3 100644 --- a/mfshell/commands/mkdir.c +++ b/mfshell/commands/mkdir.c @@ -34,6 +34,11 @@ int mfshell_cmd_mkdir(mfshell * mfshell, int argc, char *const argv[]) if (mfshell == NULL) return -1; + if (mfshell->conn == NULL) { + fprintf(stderr, "conn is NULL\n"); + return -1; + } + if (argc != 2) { fprintf(stderr, "Invalid number of arguments\n"); return -1; diff --git a/mfshell/commands/rmdir.c b/mfshell/commands/rmdir.c index c616ee3..697d54c 100644 --- a/mfshell/commands/rmdir.c +++ b/mfshell/commands/rmdir.c @@ -33,6 +33,11 @@ int mfshell_cmd_rmdir(mfshell * mfshell, int argc, char *const argv[]) if (mfshell == NULL) return -1; + if (mfshell->conn == NULL) { + fprintf(stderr, "conn is NULL\n"); + return -1; + } + if (argc != 2) { fprintf(stderr, "Invalid number of arguments\n"); return -1; diff --git a/mfshell/commands/status.c b/mfshell/commands/status.c index 9aa8cad..0321009 100644 --- a/mfshell/commands/status.c +++ b/mfshell/commands/status.c @@ -35,6 +35,11 @@ int mfshell_cmd_status(mfshell * mfshell, int argc, char *const argv[]) if (mfshell == NULL) return -1; + if (mfshell->conn == NULL) { + fprintf(stderr, "conn is NULL\n"); + return -1; + } + if (argc != 1) { fprintf(stderr, "Invalid number of arguments\n"); return -1; diff --git a/mfshell/commands/whoami.c b/mfshell/commands/whoami.c index 6e6f3e4..4046e6d 100644 --- a/mfshell/commands/whoami.c +++ b/mfshell/commands/whoami.c @@ -29,6 +29,16 @@ int mfshell_cmd_whoami(mfshell * mfshell, int argc, char *const argv[]) (void)argv; int retval; + if (mfshell == NULL) { + fprintf(stderr, "mfshell is NULL\n"); + return -1; + } + + if (mfshell->conn == NULL) { + fprintf(stderr, "conn is NULL\n"); + return -1; + } + if (argc != 1) { fprintf(stderr, "Invalid number of arguments\n"); return -1;