Deleted Added
full compact
hastd.c (256281) hastd.c (260006)
1/*-
2 * Copyright (c) 2009-2010 The FreeBSD Foundation
3 * Copyright (c) 2010-2011 Pawel Jakub Dawidek <pawel@dawidek.net>
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *

--- 15 unchanged lines hidden (view full) ---

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2009-2010 The FreeBSD Foundation
3 * Copyright (c) 2010-2011 Pawel Jakub Dawidek <pawel@dawidek.net>
4 * All rights reserved.
5 *
6 * This software was developed by Pawel Jakub Dawidek under sponsorship from
7 * the FreeBSD Foundation.
8 *

--- 15 unchanged lines hidden (view full) ---

24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: stable/10/sbin/hastd/hastd.c 246922 2013-02-17 21:12:34Z pjd $");
32__FBSDID("$FreeBSD: stable/10/sbin/hastd/hastd.c 260006 2013-12-28 19:21:22Z trociny $");
33
34#include <sys/param.h>
35#include <sys/linker.h>
36#include <sys/module.h>
37#include <sys/stat.h>
38#include <sys/wait.h>
39
40#include <err.h>

--- 760 unchanged lines hidden (view full) ---

801 version = nv_get_uint8(nvin, "version");
802 pjdlog_debug(2, "%s: version=%hhu", raddr, version);
803 if (version == 0) {
804 /*
805 * If no version is sent, it means this is protocol version 1.
806 */
807 version = 1;
808 }
33
34#include <sys/param.h>
35#include <sys/linker.h>
36#include <sys/module.h>
37#include <sys/stat.h>
38#include <sys/wait.h>
39
40#include <err.h>

--- 760 unchanged lines hidden (view full) ---

801 version = nv_get_uint8(nvin, "version");
802 pjdlog_debug(2, "%s: version=%hhu", raddr, version);
803 if (version == 0) {
804 /*
805 * If no version is sent, it means this is protocol version 1.
806 */
807 version = 1;
808 }
809 if (version > HAST_PROTO_VERSION) {
810 pjdlog_info("Remote protocol version %hhu is not supported, falling back to version %hhu.",
811 version, (unsigned char)HAST_PROTO_VERSION);
812 version = HAST_PROTO_VERSION;
813 }
814 pjdlog_debug(1, "Negotiated protocol version %hhu.", version);
815 token = nv_get_uint8_array(nvin, &size, "token");
816 /*
817 * NULL token means that this is first connection.
818 */
819 if (token != NULL && size != sizeof(res->hr_token)) {
820 pjdlog_error("Received token of invalid size from %s (expected %zu, got %zu).",
821 raddr, sizeof(res->hr_token), size);
822 goto close;

--- 97 unchanged lines hidden (view full) ---

920 }
921 }
922
923 /*
924 * Checks and cleanups are done.
925 */
926
927 if (token == NULL) {
809 token = nv_get_uint8_array(nvin, &size, "token");
810 /*
811 * NULL token means that this is first connection.
812 */
813 if (token != NULL && size != sizeof(res->hr_token)) {
814 pjdlog_error("Received token of invalid size from %s (expected %zu, got %zu).",
815 raddr, sizeof(res->hr_token), size);
816 goto close;

--- 97 unchanged lines hidden (view full) ---

914 }
915 }
916
917 /*
918 * Checks and cleanups are done.
919 */
920
921 if (token == NULL) {
922 if (version > HAST_PROTO_VERSION) {
923 pjdlog_info("Remote protocol version %hhu is not supported, falling back to version %hhu.",
924 version, (unsigned char)HAST_PROTO_VERSION);
925 version = HAST_PROTO_VERSION;
926 }
927 pjdlog_debug(1, "Negotiated protocol version %hhu.", version);
928 res->hr_version = version;
929 arc4random_buf(res->hr_token, sizeof(res->hr_token));
930 nvout = nv_alloc();
931 nv_add_uint8(nvout, version, "version");
932 nv_add_uint8_array(nvout, res->hr_token,
933 sizeof(res->hr_token), "token");
934 if (nv_error(nvout) != 0) {
935 pjdlog_common(LOG_ERR, 0, nv_error(nvout),

--- 402 unchanged lines hidden ---
928 res->hr_version = version;
929 arc4random_buf(res->hr_token, sizeof(res->hr_token));
930 nvout = nv_alloc();
931 nv_add_uint8(nvout, version, "version");
932 nv_add_uint8_array(nvout, res->hr_token,
933 sizeof(res->hr_token), "token");
934 if (nv_error(nvout) != 0) {
935 pjdlog_common(LOG_ERR, 0, nv_error(nvout),

--- 402 unchanged lines hidden ---