]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
gnutls-serv: Do not exit when a message to be echoed is received
authorAnderson Toshiyuki Sasaki <ansasaki@redhat.com>
Tue, 24 Mar 2020 08:55:08 +0000 (09:55 +0100)
committerAnderson Toshiyuki Sasaki <ansasaki@redhat.com>
Tue, 24 Mar 2020 12:52:42 +0000 (13:52 +0100)
Previously, when gnutls-serv was executed with the --echo option, it
would exit when a message to be echoed was received.  Moreover, the
server would output "Memory error" although no error occurred.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
src/serv.c

index a4dd445da801bd33ae5cc4c5a36876a152293142..414cd0546b3cf1374f171cda0a0dfd9b4fc28001 100644 (file)
@@ -1071,12 +1071,12 @@ get_response(gnutls_session_t session, char *request,
                        *response_length = strlen(*response);
                        return 1;
                } else if (ret == 0) {
+                       *response = strdup(request);
                        if (*response == NULL) {
                                fprintf(stderr, "Memory error\n");
                                return 0;
                        }
-                       *response = strdup(request);
-                       *response_length = ((*response) ? strlen(*response) : 0);
+                       *response_length = strlen(*response);
                } else {
                        *response = NULL;
                        do {