Skip to content

Commit 5ad25f8

Browse files
committed
Fixed length checking in StatFile
If a symlink resolves to a path that is longer than the maximum allowed by the protocol, currently 4088 bytes, then an error response is generated. Previously the server side would ignore an error from SendTransaction() due to the large size and the client-side would hang/timeout waiting for a response. Ticket: ENT-13542 Changelog: title
1 parent 44bb0c4 commit 5ad25f8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cf-serverd/server_common.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,10 +874,15 @@ int StatFile(ServerConnectionState *conn, char *sendbuffer, char *ofilename)
874874

875875
memset(sendbuffer, 0, CF_MSGSIZE);
876876

877+
// +3 because we need to prepend 'OK:' to the path
878+
if (strlen(linkbuf)+3 > CF_MSGSIZE) {
879+
snprintf(sendbuffer, CF_MSGSIZE, "BAD: Symlink resolves to a path too long (%ld) to send over the protocol.", strlen(linkbuf)+3);
880+
SendTransaction(conn->conn_info, sendbuffer, 0, CF_DONE);
881+
return -1;
882+
}
877883
if (cfst.cf_readlink != NULL)
878884
{
879-
strcpy(sendbuffer, "OK:");
880-
strcat(sendbuffer, cfst.cf_readlink);
885+
assert(snprintf(sendbuffer, CF_MSGSIZE, "OK:%s", linkbuf));
881886
}
882887
else
883888
{

0 commit comments

Comments
 (0)