freebsd-ports/net/samba413/files/patch-linuxisms
Timur I. Bakeyev 3887986f67 PR: 255415
254033
		252385
Security:	CVE-2021-20254

Updated net/samba412 and net/samba413 to fix CVE-2021-20254.

Also fixed:
* Incorrect include line for the bind backend(255415)
* Broken pkg-plist with NO_PYTHON(254033)
* Broken URL parsing in LDAP client(252385)
2021-05-04 02:26:52 +02:00

91 lines
2.5 KiB
Text

--- libcli/http/http.c.orig 2020-07-09 13:33:56
+++ libcli/http/http.c
@@ -141,7 +141,19 @@ static enum http_read_status http_parse_headers(struct
return HTTP_ALL_DATA_READ;
}
+#ifdef FREEBSD
+ int s0, s1, s2, s3; s0 = s1 = s2 = s3 = 0;
+ n = sscanf(line, "%n%*[^:]%n: %n%*[^\r\n]%n\r\n", &s0, &s1, &s2, &s3);
+
+ if(n >= 0) {
+ key = calloc(sizeof(char), s1-s0+1);
+ value = calloc(sizeof(char), s3-s2+1);
+
+ n = sscanf(line, "%[^:]: %[^\r\n]\r\n", key, value);
+ }
+#else
n = sscanf(line, "%m[^:]: %m[^\r\n]\r\n", &key, &value);
+#endif
if (n != 2) {
DEBUG(0, ("%s: Error parsing header '%s'\n", __func__, line));
status = HTTP_DATA_CORRUPTED;
@@ -167,7 +179,7 @@ error:
static bool http_parse_response_line(struct http_read_response_state *state)
{
bool status = true;
- char *protocol;
+ char *protocol = NULL;
char *msg = NULL;
char major;
char minor;
@@ -187,18 +199,32 @@ static bool http_parse_response_line(struct http_read_
return false;
}
+#ifdef FREEBSD
+ int s0, s1, s2, s3; s0 = s1 = s2 = s3 = 0;
+ n = sscanf(line, "%n%*[^/]%n/%c.%c %d %n%*[^\r\n]%n\r\n",
+ &s0, &s1, &major, &minor, &code, &s2, &s3);
+
+ if(n == 3) {
+ protocol = calloc(sizeof(char), s1-s0+1);
+ msg = calloc(sizeof(char), s3-s2+1);
+
+ n = sscanf(line, "%[^/]/%c.%c %d %[^\r\n]\r\n",
+ protocol, &major, &minor, &code, msg);
+ }
+#else
n = sscanf(line, "%m[^/]/%c.%c %d %m[^\r\n]\r\n",
&protocol, &major, &minor, &code, &msg);
+#endif
- DEBUG(11, ("%s: Header parsed(%i): protocol->%s, major->%c, minor->%c, "
- "code->%d, message->%s\n", __func__, n, protocol, major, minor,
- code, msg));
-
if (n != 5) {
DEBUG(0, ("%s: Error parsing header\n", __func__));
status = false;
goto error;
}
+
+ DEBUG(11, ("%s: Header parsed(%i): protocol->%s, major->%c, minor->%c, "
+ "code->%d, message->%s\n", __func__, n, protocol, major, minor,
+ code, msg));
if (major != '1') {
DEBUG(0, ("%s: Bad HTTP major number '%c'\n", __func__, major));
--- source4/libcli/ldap/ldap_client.c.orig 2020-07-09 13:33:56
+++ source4/libcli/ldap/ldap_client.c
@@ -402,8 +402,20 @@ static int ldap_parse_basic_url(
*pport = port;
return 0;
}
+#ifdef FREEBSD
+ int s0, s1; s0 = s1 = 0;
+ ret = sscanf(url, "%n%*[^:/]%n:%d", &s0, &s1, &port);
+ if(ret >= 0) {
+ host = calloc(sizeof(char), s1 - s0 + 1);
+ if (host == NULL) {
+ return ENOMEM;
+ }
+ ret = sscanf(url, "%[^:/]:%d", host, &port);
+ }
+#else
ret = sscanf(url, "%m[^:/]:%d", &host, &port);
+#endif
if (ret < 1) {
return EINVAL;
}