]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - command.c
Merge branch 'master' into next
[paraslash.git] / command.c
index 94e9ed1cbfba5e24f8f46a6b2a8ee3ad8b3a2c54..78c9106c9ff84062e874b326a386f7073e09aeca 100644 (file)
--- a/command.c
+++ b/command.c
 #include "signal.h"
 #include "version.h"
 
+/** \cond server_cmd_aux_info */
 #define SERVER_CMD_AUX_INFO(_arg) _arg,
 static const unsigned server_command_perms[] = {LSG_SERVER_CMD_AUX_INFOS};
 #undef SERVER_CMD_AUX_INFO
 #define SERVER_CMD_AUX_INFO(_arg) #_arg,
 static const char * const server_command_perms_txt[] = {LSG_SERVER_CMD_AUX_INFOS};
 #undef SERVER_CMD_AUX_INFO
+/** \endcond server_cmd_aux_info */
 
 /** Commands including options must be shorter than this. */
 #define MAX_COMMAND_LEN 32768
@@ -420,7 +422,8 @@ static int com_version(struct command_context *cc, struct lls_parse_result *lpr)
 }
 EXPORT_SERVER_CMD_HANDLER(version);
 
-/** These status items are cleared if no audio file is currently open. */
+/** \cond empty_status_items */
+/* These status items are cleared if no audio file is currently open. */
 #define EMPTY_STATUS_ITEMS \
        ITEM(path) \
        ITEM(directory) \
@@ -454,6 +457,8 @@ EXPORT_SERVER_CMD_HANDLER(version);
        ITEM(amplification) \
        ITEM(play_time) \
 
+/** \endcond empty_status_items */
+
 /*
  * Create a set of audio-file related status items with empty values. These are
  * written to stat clients when no audio file is open.
@@ -811,19 +816,11 @@ static int parse_auth_request(char *buf, int len, const struct user **u,
                *p = '\0';
                p++;
                create_argv(p, ",", &features);
-               /*
-                * Still accept sideband and AES feature requests (as a no-op)
-                * because some 0.6.x clients request them. The two checks
-                * below may be removed after 0.7.1.
-                */
                for (i = 0; features[i]; i++) {
-                       if (strcmp(features[i], "sideband") == 0)
-                               continue;
-                       if (strcmp(features[i], "aes_ctr128") == 0)
-                               continue;
                        /*
-                        * ->sha256_requested can go away after 0.7.0 but the
-                        * check has to stay until 0.9.0.
+                        * ->sha256_requested can go away after 0.7.0 so that
+                        * sha256 is used unconditionally, but we need to
+                        * accept the feature request until 0.9.0.
                         */
                        if (strcmp(features[i], "sha256") == 0)
                                cf->sha256_requested = true;
@@ -925,7 +922,8 @@ int handle_connect(int fd)
        int ret;
        unsigned char rand_buf[APC_CHALLENGE_SIZE + 2 * SESSION_KEY_LEN];
        unsigned char challenge_hash[HASH2_SIZE];
-       char *command = NULL, *buf = alloc(HANDSHAKE_BUFSIZE) /* must be on the heap */;
+       char *command = NULL, *buf = NULL, hsbuf[HANDSHAKE_BUFSIZE];
+       unsigned char *crypt_buf;
        size_t numbytes;
        struct command_context cc_struct = {.u = NULL}, *cc = &cc_struct;
        struct iovec iov;
@@ -945,16 +943,16 @@ int handle_connect(int fd)
        if (ret < 0)
                goto net_err;
        /* recv auth request line */
-       ret = recv_buffer(fd, buf, HANDSHAKE_BUFSIZE);
+       ret = recv_buffer(fd, hsbuf, HANDSHAKE_BUFSIZE);
        if (ret < 0)
                goto net_err;
-       ret = parse_auth_request(buf, ret, &cc->u, &cf);
+       ret = parse_auth_request(hsbuf, ret, &cc->u, &cf);
        if (ret < 0)
                goto net_err;
        if (cc->u) {
                get_random_bytes_or_die(rand_buf, sizeof(rand_buf));
                ret = apc_pub_encrypt(cc->u->pubkey, rand_buf, sizeof(rand_buf),
-                       (unsigned char *)buf);
+                       &crypt_buf);
                if (ret < 0)
                        goto net_err;
                numbytes = ret;
@@ -965,12 +963,12 @@ int handle_connect(int fd)
                 * fail the authentication later.
                 */
                numbytes = 256;
-               get_random_bytes_or_die((unsigned char *)buf, numbytes);
+               crypt_buf = alloc(numbytes);
+               get_random_bytes_or_die(crypt_buf, numbytes);
        }
        PARA_DEBUG_LOG("sending %d byte challenge + session key (%zu bytes)\n",
                APC_CHALLENGE_SIZE, numbytes);
-       ret = send_sb(&cc->scc, buf, numbytes, SBD_CHALLENGE, false);
-       buf = NULL;
+       ret = send_sb(&cc->scc, crypt_buf, numbytes, SBD_CHALLENGE, false);
        if (ret < 0)
                goto net_err;
        ret = recv_sb(&cc->scc, SBD_CHALLENGE_RESPONSE,