aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2022-11-21 22:41:13 +0000
committerCy Schubert <cy@FreeBSD.org>2022-12-05 20:06:14 +0000
commita8c5dca736cdaed68738c39c52a3e0e158951b28 (patch)
tree18a140ff821ffe4c2becbedc167ef8d798dc03c0
parent4e3ca7cbf77438202f8a2e4b3a1a43b1aa885f73 (diff)
security/heimdal*: The version string must always contain a terminating NUL
Should the sender send a string without a terminating NUL, ensure that the NUL terminates the string regardless. And while at it only process the version string when bytes are returned. PR: 267884 Reported by: Robert Morris <rtm@lcs.mit.edu> (cherry picked from commit d831a2fe480fe02126bd5b9aba5569c5e69f1034)
-rw-r--r--security/heimdal-devel/Makefile2
-rw-r--r--security/heimdal-devel/files/patch-lib_krb5_recvauth.c42
-rw-r--r--security/heimdal/Makefile2
-rw-r--r--security/heimdal/files/patch-lib_krb5_recvauth.c42
4 files changed, 86 insertions, 2 deletions
diff --git a/security/heimdal-devel/Makefile b/security/heimdal-devel/Makefile
index dacf23ed6f98..890391647bc5 100644
--- a/security/heimdal-devel/Makefile
+++ b/security/heimdal-devel/Makefile
@@ -1,6 +1,6 @@
PORTNAME= heimdal
PORTVERSION= ${HEIMDAL_COMMIT_DATE}
-PORTREVISION= 2
+PORTREVISION= 3
CATEGORIES= security
PKGNAMESUFFIX= -devel
HASH= 8f9c2d115
diff --git a/security/heimdal-devel/files/patch-lib_krb5_recvauth.c b/security/heimdal-devel/files/patch-lib_krb5_recvauth.c
new file mode 100644
index 000000000000..95d8acf15baf
--- /dev/null
+++ b/security/heimdal-devel/files/patch-lib_krb5_recvauth.c
@@ -0,0 +1,42 @@
+--- lib/krb5/recvauth.c.orig 2022-09-15 16:54:19.000000000 -0700
++++ lib/krb5/recvauth.c 2022-11-21 14:37:31.130429000 -0800
+@@ -98,7 +98,7 @@
+ const char *version = KRB5_SENDAUTH_VERSION;
+ char her_version[sizeof(KRB5_SENDAUTH_VERSION)];
+ char *her_appl_version;
+- uint32_t len;
++ uint32_t len, bytes;
+ u_char repl;
+ krb5_data data;
+ krb5_flags ap_options;
+@@ -166,15 +166,21 @@
+ krb5_net_write (context, p_fd, &repl, 1);
+ return krb5_enomem(context);
+ }
+- if (krb5_net_read (context, p_fd, her_appl_version, len) != len
+- || !(*match_appl_version)(match_data, her_appl_version)) {
+- repl = 2;
+- krb5_net_write (context, p_fd, &repl, 1);
+- krb5_set_error_message(context, KRB5_SENDAUTH_BADAPPLVERS,
+- N_("wrong sendauth application version (%s)", ""),
+- her_appl_version);
+- free (her_appl_version);
+- return KRB5_SENDAUTH_BADAPPLVERS;
++ if ((bytes = krb5_net_read (context, p_fd, her_appl_version, len))) {
++ /* PR/267884: String read must always conatain a terminating NUL */
++ if (strnlen(her_appl_version, len) == len)
++ her_appl_version[len-1] = '\0';
++
++ if (bytes != len ||
++ !(*match_appl_version)(match_data, her_appl_version)) {
++ repl = 2;
++ krb5_net_write (context, p_fd, &repl, 1);
++ krb5_set_error_message(context, KRB5_SENDAUTH_BADAPPLVERS,
++ N_("wrong sendauth application version (%s)", ""),
++ her_appl_version);
++ free (her_appl_version);
++ return KRB5_SENDAUTH_BADAPPLVERS;
++ }
+ }
+ free (her_appl_version);
+
diff --git a/security/heimdal/Makefile b/security/heimdal/Makefile
index 6508bf471ee0..3d92a0c2fd3b 100644
--- a/security/heimdal/Makefile
+++ b/security/heimdal/Makefile
@@ -1,6 +1,6 @@
PORTNAME= heimdal
PORTVERSION= 7.8.0
-PORTREVISION= 3
+PORTREVISION= 4
CATEGORIES= security
MASTER_SITES= https://github.com/heimdal/heimdal/releases/download/${DISTNAME}/
diff --git a/security/heimdal/files/patch-lib_krb5_recvauth.c b/security/heimdal/files/patch-lib_krb5_recvauth.c
new file mode 100644
index 000000000000..95d8acf15baf
--- /dev/null
+++ b/security/heimdal/files/patch-lib_krb5_recvauth.c
@@ -0,0 +1,42 @@
+--- lib/krb5/recvauth.c.orig 2022-09-15 16:54:19.000000000 -0700
++++ lib/krb5/recvauth.c 2022-11-21 14:37:31.130429000 -0800
+@@ -98,7 +98,7 @@
+ const char *version = KRB5_SENDAUTH_VERSION;
+ char her_version[sizeof(KRB5_SENDAUTH_VERSION)];
+ char *her_appl_version;
+- uint32_t len;
++ uint32_t len, bytes;
+ u_char repl;
+ krb5_data data;
+ krb5_flags ap_options;
+@@ -166,15 +166,21 @@
+ krb5_net_write (context, p_fd, &repl, 1);
+ return krb5_enomem(context);
+ }
+- if (krb5_net_read (context, p_fd, her_appl_version, len) != len
+- || !(*match_appl_version)(match_data, her_appl_version)) {
+- repl = 2;
+- krb5_net_write (context, p_fd, &repl, 1);
+- krb5_set_error_message(context, KRB5_SENDAUTH_BADAPPLVERS,
+- N_("wrong sendauth application version (%s)", ""),
+- her_appl_version);
+- free (her_appl_version);
+- return KRB5_SENDAUTH_BADAPPLVERS;
++ if ((bytes = krb5_net_read (context, p_fd, her_appl_version, len))) {
++ /* PR/267884: String read must always conatain a terminating NUL */
++ if (strnlen(her_appl_version, len) == len)
++ her_appl_version[len-1] = '\0';
++
++ if (bytes != len ||
++ !(*match_appl_version)(match_data, her_appl_version)) {
++ repl = 2;
++ krb5_net_write (context, p_fd, &repl, 1);
++ krb5_set_error_message(context, KRB5_SENDAUTH_BADAPPLVERS,
++ N_("wrong sendauth application version (%s)", ""),
++ her_appl_version);
++ free (her_appl_version);
++ return KRB5_SENDAUTH_BADAPPLVERS;
++ }
+ }
+ free (her_appl_version);
+