aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2012-10-05 10:37:53 +0200
committerAndreas Schneider <asn@cryptomilk.org>2012-10-05 11:12:14 +0200
commit22f607649d7dc530df84b7b90781ce0b88153095 (patch)
treebe96ff236cf825ccd86f8991d9bd6d9caa850c55 /src
parentb5c4b090da254c1ad3689983b0cb999b09aa3394 (diff)
downloadlibssh-22f607649d7dc530df84b7b90781ce0b88153095.tar.gz
libssh-22f607649d7dc530df84b7b90781ce0b88153095.tar.xz
libssh-22f607649d7dc530df84b7b90781ce0b88153095.zip
sftp: Harden sftp_extension_supported() against null pointers.
Diffstat (limited to 'src')
-rw-r--r--src/sftp.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/sftp.c b/src/sftp.c
index 822360af..60afdc2f 100644
--- a/src/sftp.c
+++ b/src/sftp.c
@@ -622,10 +622,18 @@ int sftp_extension_supported(sftp_session sftp, const char *name,
const char *data) {
int i, n;
+ if (sftp == NULL || name == NULL || data == NULL) {
+ return 0;
+ }
+
n = sftp_extensions_get_count(sftp);
for (i = 0; i < n; i++) {
- if (strcmp(sftp_extensions_get_name(sftp, i), name) == 0 &&
- strcmp(sftp_extensions_get_data(sftp, i), data) == 0) {
+ const char *ext_name = sftp_extensions_get_name(sftp, i);
+ const char *ext_data = sftp_extensions_get_data(sftp, i);
+
+ if (ext_name != NULL && ext_data != NULL &&
+ strcmp(ext_name, name) == 0 &&
+ strcmp(ext_data, data) == 0) {
return 1;
}
}