Skip to content

Commit 8660fb1

Browse files
committed
GHSL-2023-010: Memory leak when parsing usernames
Memory leak when parsing usernames (GHSL-2023-010) Fixes defect GHSL-2023-010 found by the GitHub Security Lab team via oss-fuzz. The domain portion may be overridden causing an allocated memory area the size of the domain name to be lost. This could be used to mount a DoS by depleeting the server memory. Signed-off-by: Simo Sorce <simo@redhat.com>
1 parent 025fbb7 commit 8660fb1

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/gss_names.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ static uint32_t parse_user_name(uint32_t *minor_status,
136136
/* we may have an enterprise name here */
137137
char strbuf[len + 1];
138138
char *buf = strbuf;
139-
bool domain_handled = false;
140139

141140
/* copy buf to manipulate it */
142141
memcpy(buf, str, len);
@@ -160,9 +159,6 @@ static uint32_t parse_user_name(uint32_t *minor_status,
160159
}
161160

162161
if (sep) {
163-
/* leading domain, copy if domain name is not empty */
164-
domain_handled = true;
165-
166162
/* terminate and copy domain, even if empty */
167163
/* NOTE: this is important for the Windbind integration case
168164
* where we need to tell the machinery to *not* add the default
@@ -180,7 +176,7 @@ static uint32_t parse_user_name(uint32_t *minor_status,
180176

181177
for (at = strchr(buf, '@'); at != NULL; at = strchr(at, '@')) {
182178
if (*(at - 1) == '\\') {
183-
if (domain_handled) {
179+
if (*domain) {
184180
/* Invalid forms like DOM\foo\@bar or foo@bar\@baz */
185181
free(*domain);
186182
*domain = NULL;
@@ -189,7 +185,7 @@ static uint32_t parse_user_name(uint32_t *minor_status,
189185
}
190186
/* remove escape, moving all including terminating '\0' */
191187
memmove(at - 1, at, len - (at - buf) + 1);
192-
} else if (!domain_handled) {
188+
} else if (!*domain) {
193189
/* an '@' without escape and no previous
194190
* domain was split out.
195191
* the rest of the string is the domain */

0 commit comments

Comments
 (0)