From 68bb902a4ea386103733f19c02198b18dd3b94f2 Mon Sep 17 00:00:00 2001 From: Gerrit Renker Date: Sun, 7 Feb 2010 20:20:28 +0000 Subject: [PATCH] --- yaml --- r: 184005 b: refs/heads/master c: 69a6a0b38a139ccceef32222108caca8a9b0b795 h: refs/heads/master i: 184003: e518edccb04f2086cf89664c6f43b5fc03ab7141 v: v3 --- [refs] | 2 +- trunk/Documentation/networking/dccp.txt | 6 ++++-- trunk/net/dccp/ccid.c | 9 ++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/[refs] b/[refs] index 8420eda1dfd9..2e6df8cd0ede 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 7455a76f170f794498d26081a5f15b797ef1a2aa +refs/heads/master: 69a6a0b38a139ccceef32222108caca8a9b0b795 diff --git a/trunk/Documentation/networking/dccp.txt b/trunk/Documentation/networking/dccp.txt index b132e4a3cf0f..a62fdf7a6bff 100644 --- a/trunk/Documentation/networking/dccp.txt +++ b/trunk/Documentation/networking/dccp.txt @@ -58,8 +58,10 @@ DCCP_SOCKOPT_GET_CUR_MPS is read-only and retrieves the current maximum packet size (application payload size) in bytes, see RFC 4340, section 14. DCCP_SOCKOPT_AVAILABLE_CCIDS is also read-only and returns the list of CCIDs -supported by the endpoint (see include/linux/dccp.h for symbolic constants). -The caller needs to provide a sufficiently large (> 2) array of type uint8_t. +supported by the endpoint. The option value is an array of type uint8_t whose +size is passed as option length. The minimum array size is 4 elements, the +value returned in the optlen argument always reflects the true number of +built-in CCIDs. DCCP_SOCKOPT_CCID is write-only and sets both the TX and RX CCIDs at the same time, combining the operation of the next two socket options. This option is diff --git a/trunk/net/dccp/ccid.c b/trunk/net/dccp/ccid.c index ff16e9df1969..49d27c556bec 100644 --- a/trunk/net/dccp/ccid.c +++ b/trunk/net/dccp/ccid.c @@ -63,14 +63,13 @@ int ccid_getsockopt_builtin_ccids(struct sock *sk, int len, u8 *ccid_array, array_len; int err = 0; - if (len < ARRAY_SIZE(ccids)) - return -EINVAL; - if (ccid_get_builtin_ccids(&ccid_array, &array_len)) return -ENOBUFS; - if (put_user(array_len, optlen) || - copy_to_user(optval, ccid_array, array_len)) + if (put_user(array_len, optlen)) + err = -EFAULT; + else if (len > 0 && copy_to_user(optval, ccid_array, + len > array_len ? array_len : len)) err = -EFAULT; kfree(ccid_array);