summaryrefslogtreecommitdiff
path: root/cifscreds.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@samba.org>2014-04-20 20:41:05 -0400
committerJeff Layton <jlayton@samba.org>2014-04-20 20:41:08 -0400
commit3da4c43b575498be86c87a2ac3f3142e3cab1c59 (patch)
tree172aef6b75c84b6894c213c7fc3ba4ff0e208ddc /cifscreds.c
parent0c521d5060035da655107001374e08873ac5dde8 (diff)
downloadcifs-utils-3da4c43b575498be86c87a2ac3f3142e3cab1c59.tar.gz
cifs-utils-3da4c43b575498be86c87a2ac3f3142e3cab1c59.tar.bz2
cifs-utils-3da4c43b575498be86c87a2ac3f3142e3cab1c59.zip
cifscreds: better error handling when key_search fails
If we ended up getting a bogus string that would have overflowed, then make key_search set errno to EINVAL before returning. The callers can then test to see if the returned error is what was expected or something else and handle it appropriately. Cc: Sebastian Krahmer <krahmer@suse.de> Signed-off-by: Jeff Layton <jlayton@samba.org>
Diffstat (limited to 'cifscreds.c')
-rw-r--r--cifscreds.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/cifscreds.c b/cifscreds.c
index fa05dc8..64d55b0 100644
--- a/cifscreds.c
+++ b/cifscreds.c
@@ -188,6 +188,15 @@ static int cifscreds_add(struct cmdarg *arg)
return EXIT_FAILURE;
}
+ switch(errno) {
+ case ENOKEY:
+ /* success */
+ break;
+ default:
+ printf("Key search failed: %s\n", strerror(errno));
+ return EXIT_FAILURE;
+ }
+
currentaddress = nextaddress;
if (currentaddress) {
*(currentaddress - 1) = ',';