Blame ecryptfs-utils-75-werror.patch

58fe0d
diff -up ecryptfs-utils-109/src/key_mod/ecryptfs_key_mod_pkcs11_helper.c.werror ecryptfs-utils-109/src/key_mod/ecryptfs_key_mod_pkcs11_helper.c
58fe0d
--- ecryptfs-utils-109/src/key_mod/ecryptfs_key_mod_pkcs11_helper.c.werror	2016-01-26 16:00:55.718289254 +0100
58fe0d
+++ ecryptfs-utils-109/src/key_mod/ecryptfs_key_mod_pkcs11_helper.c	2016-01-26 16:00:55.725289240 +0100
75b89e
@@ -98,7 +98,7 @@ static int ecryptfs_pkcs11h_deserialize(
Michal Hlavinka 79c27c
 		pkcs11h_data->serialized_id = NULL;
Michal Hlavinka 79c27c
 	}
Michal Hlavinka 79c27c
 	else {
Michal Hlavinka 79c27c
-		pkcs11h_data->serialized_id = blob + i;
Michal Hlavinka 79c27c
+		pkcs11h_data->serialized_id = (char *)blob + i;
Michal Hlavinka 79c27c
 		i += serialized_id_length;
Michal Hlavinka 79c27c
 	}
Michal Hlavinka 79c27c
 	pkcs11h_data->certificate_blob_size = blob[i++] % 256;
75b89e
@@ -116,12 +116,11 @@ static int ecryptfs_pkcs11h_deserialize(
Michal Hlavinka 79c27c
 		pkcs11h_data->passphrase = NULL;
Michal Hlavinka 79c27c
 	}
Michal Hlavinka 79c27c
 	else {
Michal Hlavinka 79c27c
-		pkcs11h_data->passphrase = blob + i;
Michal Hlavinka 79c27c
+		pkcs11h_data->passphrase = (char *)blob + i;
Michal Hlavinka 79c27c
 		i += passphrase_length;
Michal Hlavinka 79c27c
 	}
Michal Hlavinka 79c27c
 
Michal Hlavinka 79c27c
 	rc = 0;
Michal Hlavinka 79c27c
-out:
Michal Hlavinka 79c27c
 	return rc;
Michal Hlavinka 79c27c
 }
Michal Hlavinka 79c27c
 
75b89e
@@ -358,14 +357,14 @@ static int ecryptfs_pkcs11h_get_key_sig(
Michal Hlavinka 79c27c
 	data[i++] = '\02';
Michal Hlavinka 79c27c
 	data[i++] = (char)(nbits >> 8);
Michal Hlavinka 79c27c
 	data[i++] = (char)nbits;
Michal Hlavinka 79c27c
-	BN_bn2bin(rsa->n, &(data[i]));
Michal Hlavinka 79c27c
+	BN_bn2bin(rsa->n, (unsigned char *)&(data[i]));
Michal Hlavinka 79c27c
 	i += nbytes;
Michal Hlavinka 79c27c
 	data[i++] = (char)(ebits >> 8);
Michal Hlavinka 79c27c
 	data[i++] = (char)ebits;
Michal Hlavinka 79c27c
-	BN_bn2bin(rsa->e, &(data[i]));
Michal Hlavinka 79c27c
+	BN_bn2bin(rsa->e, (unsigned char *)&(data[i]));
Michal Hlavinka 79c27c
 	i += ebytes;
Michal Hlavinka 79c27c
-	SHA1(data, len + 3, hash);
Michal Hlavinka 79c27c
-	to_hex(sig, hash, ECRYPTFS_SIG_SIZE);
Michal Hlavinka 79c27c
+	SHA1((unsigned char *)data, len + 3, (unsigned char *)hash);
Michal Hlavinka 79c27c
+	to_hex((char *)sig, hash, ECRYPTFS_SIG_SIZE);
Michal Hlavinka 79c27c
 	sig[ECRYPTFS_SIG_SIZE_HEX] = '\0';
Michal Hlavinka 79c27c
 
Michal Hlavinka 79c27c
 	rc = 0;
75b89e
@@ -423,8 +422,8 @@ static int ecryptfs_pkcs11h_encrypt(char
Michal Hlavinka 79c27c
 		if (
Michal Hlavinka 79c27c
 			(rc = RSA_public_encrypt(
Michal Hlavinka 79c27c
 				from_size,
Michal Hlavinka 79c27c
-				from,
Michal Hlavinka 79c27c
-				to,
Michal Hlavinka 79c27c
+				(unsigned char *)from,
Michal Hlavinka 79c27c
+				(unsigned char *)to,
Michal Hlavinka 79c27c
 				rsa,
Michal Hlavinka 79c27c
 				RSA_PKCS1_PADDING
Michal Hlavinka 79c27c
 			)) == -1
75b89e
@@ -518,9 +517,9 @@ static int ecryptfs_pkcs11h_decrypt(char
Michal Hlavinka 79c27c
 		(rv = pkcs11h_certificate_decryptAny (
Michal Hlavinka 79c27c
 			certificate,
Michal Hlavinka 79c27c
 			CKM_RSA_PKCS,
Michal Hlavinka 79c27c
-			from,
Michal Hlavinka 79c27c
+			(unsigned char *)from,
Michal Hlavinka 79c27c
 			from_size,
Michal Hlavinka 79c27c
-			to,
Michal Hlavinka 79c27c
+			(unsigned char *)to,
Michal Hlavinka 79c27c
 			to_size
Michal Hlavinka 79c27c
 		)) != CKR_OK
Michal Hlavinka 79c27c
 	) {
75b89e
@@ -546,9 +545,9 @@ static int ecryptfs_pkcs11h_decrypt(char
Michal Hlavinka 79c27c
 		pkcs11h_certificate_decryptAny (
Michal Hlavinka 79c27c
 			certificate,
Michal Hlavinka 79c27c
 			CKM_RSA_PKCS,
Michal Hlavinka 79c27c
-			from,
Michal Hlavinka 79c27c
+			(unsigned char *)from,
Michal Hlavinka 79c27c
 			from_size,
Michal Hlavinka 79c27c
-			tmp,
Michal Hlavinka 79c27c
+			(unsigned char *)tmp,
Michal Hlavinka 79c27c
 			to_size
Michal Hlavinka 79c27c
 		);
Michal Hlavinka 79c27c
 
75b89e
@@ -863,7 +862,7 @@ static int ecryptfs_pkcs11h_process_key(
Michal Hlavinka 79c27c
 		rc = MOUNT_ERROR;
Michal Hlavinka 79c27c
 		goto out;
Michal Hlavinka 79c27c
 	}
Michal Hlavinka 79c27c
-	if ((rc = ecryptfs_pkcs11h_serialize(subgraph_key_ctx->key_mod->blob,
Michal Hlavinka 79c27c
+	if ((rc = ecryptfs_pkcs11h_serialize((unsigned char *)subgraph_key_ctx->key_mod->blob,
Michal Hlavinka 79c27c
 					     &subgraph_key_ctx->key_mod->blob_size, 
Michal Hlavinka 79c27c
 					     pkcs11h_data))) {
Michal Hlavinka 79c27c
 		syslog(LOG_ERR, "PKCS#11: Error serializing pkcs11; rc=[%d]\n", rc);
75b89e
@@ -942,7 +941,7 @@ static int tf_pkcs11h_global_loglevel(st
Michal Hlavinka 79c27c
 
Michal Hlavinka 79c27c
 	rc = DEFAULT_TOK;
Michal Hlavinka 79c27c
 	node->val = NULL;
Michal Hlavinka 79c27c
-out:
Michal Hlavinka 79c27c
+// out:
Michal Hlavinka 79c27c
 	return rc;
Michal Hlavinka 79c27c
 }
Michal Hlavinka 79c27c
 
75b89e
@@ -955,7 +954,7 @@ static int tf_pkcs11h_global_pincache(st
Michal Hlavinka 79c27c
 
Michal Hlavinka 79c27c
 	rc = DEFAULT_TOK;
Michal Hlavinka 79c27c
 	node->val = NULL;
Michal Hlavinka 79c27c
-out:
Michal Hlavinka 79c27c
+// out:
Michal Hlavinka 79c27c
 	return rc;
Michal Hlavinka 79c27c
 }
Michal Hlavinka 79c27c
 
75b89e
@@ -1025,7 +1024,7 @@ static int tf_pkcs11h_provider_prot_auth
Michal Hlavinka 79c27c
 	sscanf (node->val, "%x", &subgraph_provider_ctx->allow_protected_authentication);
Michal Hlavinka 79c27c
 	rc = DEFAULT_TOK;
Michal Hlavinka 79c27c
 	node->val = NULL;
Michal Hlavinka 79c27c
-out:
Michal Hlavinka 79c27c
+
Michal Hlavinka 79c27c
 	return rc;
Michal Hlavinka 79c27c
 }
Michal Hlavinka 79c27c
 
75b89e
@@ -1039,7 +1038,7 @@ static int tf_pkcs11h_provider_cert_priv
Michal Hlavinka 79c27c
 	sscanf (node->val, "%x", &subgraph_provider_ctx->certificate_is_private);
Michal Hlavinka 79c27c
 	rc = DEFAULT_TOK;
Michal Hlavinka 79c27c
 	node->val = NULL;
Michal Hlavinka 79c27c
-out:
Michal Hlavinka 79c27c
+
Michal Hlavinka 79c27c
 	return rc;
Michal Hlavinka 79c27c
 }
Michal Hlavinka 79c27c
 
75b89e
@@ -1054,7 +1053,7 @@ static int tf_pkcs11h_provider_private_m
Michal Hlavinka 79c27c
 
Michal Hlavinka 79c27c
 	rc = DEFAULT_TOK;
Michal Hlavinka 79c27c
 	node->val = NULL;
Michal Hlavinka 79c27c
-out:
Michal Hlavinka 79c27c
+
Michal Hlavinka 79c27c
 	return rc;
Michal Hlavinka 79c27c
 }
Michal Hlavinka 79c27c
 
75b89e
@@ -1085,7 +1084,7 @@ static int tf_pkcs11h_provider_end(struc
Michal Hlavinka 79c27c
 	free(subgraph_provider_ctx);
Michal Hlavinka 79c27c
 	*foo = NULL;
Michal Hlavinka 79c27c
 	rc = DEFAULT_TOK;
Michal Hlavinka 79c27c
-out:
Michal Hlavinka 79c27c
+
Michal Hlavinka 79c27c
 	return rc;
Michal Hlavinka 79c27c
 }
Michal Hlavinka 79c27c
 
75b89e
@@ -1132,7 +1131,7 @@ static int tf_pkcs11h_key_x509file(struc
9f5906
 	X509 *x509 = NULL;
9f5906
 	unsigned char *p = NULL;
9f5906
 	FILE *fp = NULL;
9f5906
-	int rc;
9f5906
+	int rc = 0;
9f5906
 
9f5906
 	subgraph_key_ctx = (struct pkcs11h_subgraph_key_ctx *)(*foo);
9f5906
 
58fe0d
diff -up ecryptfs-utils-109/src/pam_ecryptfs/pam_ecryptfs.c.werror ecryptfs-utils-109/src/pam_ecryptfs/pam_ecryptfs.c
58fe0d
--- ecryptfs-utils-109/src/pam_ecryptfs/pam_ecryptfs.c.werror	2015-12-21 21:38:59.000000000 +0100
58fe0d
+++ ecryptfs-utils-109/src/pam_ecryptfs/pam_ecryptfs.c	2016-01-26 16:00:55.725289240 +0100
75b89e
@@ -84,9 +84,7 @@ static int wrap_passphrase_if_necessary(
bcbcca
 	    stat(wrapped_pw_filename, &s) != 0  &&
bcbcca
 	    passphrase != NULL && *passphrase != '\0' &&
bcbcca
 	    username != NULL && *username != '\0') {
bcbcca
-		setuid(uid);
bcbcca
-		rc = ecryptfs_wrap_passphrase_file(wrapped_pw_filename, passphrase, salt, unwrapped_pw_filename);
bcbcca
-		if (rc != 0) {
bcbcca
+		if ((rc = setuid(uid))<0 || ((rc = ecryptfs_wrap_passphrase_file(wrapped_pw_filename, passphrase, salt, unwrapped_pw_filename)) != 0)) {
a2657e
 			syslog(LOG_ERR, "pam_ecryptfs: Error wrapping cleartext password; " "rc = [%d]\n", rc);
bcbcca
 		}
bcbcca
 		return rc;
9471b7
@@ -356,7 +354,7 @@ static int private_dir(pam_handle_t *pam
Michal Hlavinka 538613
 			if (stat(recorded, &s) != 0 && stat("/usr/share/ecryptfs-utils/ecryptfs-record-passphrase", &s) == 0) {
Michal Hlavinka 538613
 				/* User has not recorded their passphrase */
Michal Hlavinka 538613
 				unlink("/var/lib/update-notifier/user.d/ecryptfs-record-passphrase");
Michal Hlavinka 538613
-				symlink("/usr/share/ecryptfs-utils/ecryptfs-record-passphrase", "/var/lib/update-notifier/user.d/ecryptfs-record-passphrase");
Michal Hlavinka 538613
+				rc=symlink("/usr/share/ecryptfs-utils/ecryptfs-record-passphrase", "/var/lib/update-notifier/user.d/ecryptfs-record-passphrase");
Michal Hlavinka 538613
 				fd = open("/var/lib/update-notifier/dpkg-run-stamp", O_WRONLY|O_CREAT|O_NONBLOCK, 0666);
75b89e
 				if (fd != -1)
75b89e
 					close(fd);
9471b7
@@ -517,7 +515,10 @@ PAM_EXTERN int pam_sm_chauthtok(pam_hand
bcbcca
 		char passphrase[ECRYPTFS_MAX_PASSWORD_LENGTH + 1];
bcbcca
 
bcbcca
 		/* temp regain uid 0 to drop privs */
bcbcca
-		seteuid(oeuid);
bcbcca
+		if (seteuid(oeuid) < 0) {
bcbcca
+			syslog(LOG_ERR, "pam_ecryptfs: seteuid error");
bcbcca
+			goto out_child;
bcbcca
+		}
bcbcca
 		/* setgroups() already called */
bcbcca
 		if (setgid(gid) < 0 || setuid(uid) < 0)
bcbcca
 			goto out_child;
9471b7
@@ -542,9 +543,9 @@ out_child:
bcbcca
 	free(wrapped_pw_filename);
bcbcca
 out:
bcbcca
 
bcbcca
-	seteuid(oeuid);
bcbcca
-	setegid(oegid);
bcbcca
-	setgroups(ngids, groups);
bcbcca
+	rc = seteuid(oeuid);
bcbcca
+	rc = setegid(oegid);
bcbcca
+	rc = setgroups(ngids, groups);
bcbcca
 
bcbcca
 outnouid:
bcbcca
 	return rc;
58fe0d
diff -up ecryptfs-utils-109/src/utils/ecryptfs_generate_tpm_key.c.werror ecryptfs-utils-109/src/utils/ecryptfs_generate_tpm_key.c
58fe0d
--- ecryptfs-utils-109/src/utils/ecryptfs_generate_tpm_key.c.werror	2015-12-21 21:38:59.000000000 +0100
58fe0d
+++ ecryptfs-utils-109/src/utils/ecryptfs_generate_tpm_key.c	2016-01-26 16:00:55.726289238 +0100
9471b7
@@ -89,7 +89,7 @@ int main(int argc, char **argv)
9471b7
 	int i, c, *pcrsSelected = NULL, numPcrsSelected = 0;
9471b7
 	TSS_UUID *uuid;
9471b7
 	BYTE wellknown[] = TSS_WELL_KNOWN_SECRET;
9471b7
-	char *tmp_pcrs;
9471b7
+	int *tmp_pcrs;
9471b7
 
9471b7
 	while (1) {
9471b7
 		c = getopt(argc, argv, "p:");
58fe0d
diff -up ecryptfs-utils-109/src/utils/mount.ecryptfs_private.c.werror ecryptfs-utils-109/src/utils/mount.ecryptfs_private.c
58fe0d
--- ecryptfs-utils-109/src/utils/mount.ecryptfs_private.c.werror	2016-01-26 16:00:55.723289244 +0100
58fe0d
+++ ecryptfs-utils-109/src/utils/mount.ecryptfs_private.c	2016-01-26 16:02:03.487148717 +0100
58fe0d
@@ -232,7 +232,7 @@ static int check_cwd_f_type()
58fe0d
 	 *
58fe0d
 	 * This whitelist is to prevent malicious mount.ecryptfs_private users
58fe0d
 	 * from mounting over filesystem types such as PROC_SUPER_MAGIC to
58fe0d
-	 * deceive other programs with a crafted /proc/self/*. See
58fe0d
+	 * deceive other programs with a crafted /proc/self/ *. See
58fe0d
 	 * https://launchpad.net/bugs/1530566 for more details.
58fe0d
 	 */
58fe0d
 	__SWORD_TYPE f_type_whitelist[] = {
58fe0d
@@ -829,8 +829,8 @@ int main(int argc, char *argv[]) {
bcbcca
  		 * update mtab for us, and replace the current process.
bcbcca
 		 * Do not use the umount.ecryptfs helper (-i).
bcbcca
  		 */
bcbcca
-		setresuid(0,0,0);
bcbcca
-		setresgid(0,0,0);
bcbcca
+		rc=setresuid(0,0,0);
bcbcca
+		rc=setresgid(0,0,0);
bcbcca
 		clearenv();
bcbcca
 
bcbcca
 		/* Since we're doing a lazy unmount anyway, just unmount the current
58fe0d
diff -up ecryptfs-utils-109/tests/kernel/inode-race-stat/test.c.werror ecryptfs-utils-109/tests/kernel/inode-race-stat/test.c
58fe0d
--- ecryptfs-utils-109/tests/kernel/inode-race-stat/test.c.werror	2015-12-21 21:38:59.000000000 +0100
58fe0d
+++ ecryptfs-utils-109/tests/kernel/inode-race-stat/test.c	2016-01-26 16:00:55.726289238 +0100
75b89e
@@ -364,6 +364,7 @@ abort:
75b89e
 
75b89e
 		if (write(pipe_to[i][1], cmd, 1) != 1)
75b89e
 			continue;
a7b4e2
+		(void)ret;
a7b4e2
 		(void)waitpid(pids[i], &status, 0);
a7b4e2
 
a7b4e2
 		(void)close(pipe_to[i][1]);