aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnderson Toshiyuki Sasaki <ansasaki@redhat.com>2018-09-25 16:44:06 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-09-27 15:39:20 +0200
commite23c28a82b2781793a5c5cc22e37379f6490d0d5 (patch)
tree32afc9c821e0e4b907420645662ab41e4ef00813
parent7291b50420e72a54859ac47539dec7e7dccd3ce7 (diff)
downloadlibssh-e23c28a82b2781793a5c5cc22e37379f6490d0d5.tar.gz
libssh-e23c28a82b2781793a5c5cc22e37379f6490d0d5.tar.xz
libssh-e23c28a82b2781793a5c5cc22e37379f6490d0d5.zip
examples: Add null checks in libssh_scp.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit 31202822a720221773b32623ee582a8ed4722867)
-rw-r--r--examples/libssh_scp.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/examples/libssh_scp.c b/examples/libssh_scp.c
index 7a17e46c..ff38b830 100644
--- a/examples/libssh_scp.c
+++ b/examples/libssh_scp.c
@@ -408,6 +408,11 @@ int main(int argc, char **argv) {
}
dest = parse_location(destination);
+ if (dest == NULL) {
+ r = EXIT_FAILURE;
+ goto end;
+ }
+
if (open_location(dest, WRITE) < 0) {
location_free(dest);
r = EXIT_FAILURE;
@@ -416,6 +421,11 @@ int main(int argc, char **argv) {
for (i = 0; i < nsources; ++i) {
src = parse_location(sources[i]);
+ if (src == NULL) {
+ r = EXIT_FAILURE;
+ goto close_dest;
+ }
+
if (open_location(src, READ) < 0) {
location_free(src);
r = EXIT_FAILURE;