Skip to content

Commit

Permalink
[Server] Fix uncontrolled format string in XrdXrootdTpcMon
Browse files Browse the repository at this point in the history
The format string in urlFMT is built from strings which come from
the environment, so one could pass in malicious strings that would
alter the actual format being used in XrdXrootdTpcMon::getURL().
  • Loading branch information
amadio committed Nov 26, 2024
1 parent 50209b3 commit a1bcd44
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/XrdXrootd/XrdXrootdTpcMon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const char *json_fmt = "{\"TPC\":\"%s\",\"Client\":\"%s\","
"\"IPv\":%c},"
"\"Src\":\"%s\",\"Dst\":\"%s\",\"Size\":%zu}";

const char *urlFMT = "";
const char *hostport = "";

XrdSysError eDest(0, "Ouc");
}
Expand All @@ -72,8 +72,8 @@ XrdXrootdTpcMon::XrdXrootdTpcMon(const char *proto,
const char *host = getenv("XRDHOST"); if (!host) host = "localhost";
const char *port = getenv("XRDPORT"); if (!port) {colon = ""; port = "";}

snprintf(buff, sizeof(buff), "%%s://%s%s%s/%%s", host, colon, port);
urlFMT = strdup(buff);
snprintf(buff, sizeof(buff), "%s%s%s", host, colon, port);
hostport = strdup(buff);
}

/******************************************************************************/
Expand All @@ -86,7 +86,7 @@ const char *XrdXrootdTpcMon::getURL(const char *spec, const char *prot,
// Handle the spec
//
if (*spec == '/')
{snprintf(buff, bsz, urlFMT, prot, spec);
{snprintf(buff, bsz, "%s://%s/%s", prot, hostport, spec);
spec = buff;
}
return spec;
Expand Down

0 comments on commit a1bcd44

Please sign in to comment.