diff options
author | djm@openbsd.org <djm@openbsd.org> | 2016-05-02 08:49:03 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2016-05-02 20:35:04 +1000 |
commit | 1a31d02b2411c4718de58ce796dbb7b5e14db93e (patch) | |
tree | c6e06a9890e71bc97cd3cdc6ce74919e504c8fd8 /monitor.c | |
parent | d2d6bf864e52af8491a60dd507f85b74361f5da3 (diff) |
upstream commit
fix signed/unsigned errors reported by clang-3.7; add
sshbuf_dup_string() to replace a common idiom of strdup(sshbuf_ptr()) with
better safety checking; feedback and ok markus@
Upstream-ID: 71f926d9bb3f1efed51319a6daf37e93d57c8820
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 27 |
1 files changed, 16 insertions, 11 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: monitor.c,v 1.158 2016/03/07 19:02:43 djm Exp $ */ | 1 | /* $OpenBSD: monitor.c,v 1.159 2016/05/02 08:49:03 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright 2002 Niels Provos <provos@citi.umich.edu> | 3 | * Copyright 2002 Niels Provos <provos@citi.umich.edu> |
4 | * Copyright 2002 Markus Friedl <markus@openbsd.org> | 4 | * Copyright 2002 Markus Friedl <markus@openbsd.org> |
@@ -34,6 +34,7 @@ | |||
34 | 34 | ||
35 | #include <errno.h> | 35 | #include <errno.h> |
36 | #include <fcntl.h> | 36 | #include <fcntl.h> |
37 | #include <limits.h> | ||
37 | #ifdef HAVE_PATHS_H | 38 | #ifdef HAVE_PATHS_H |
38 | #include <paths.h> | 39 | #include <paths.h> |
39 | #endif | 40 | #endif |
@@ -688,7 +689,8 @@ mm_answer_sign(int sock, Buffer *m) | |||
688 | u_char *p = NULL, *signature = NULL; | 689 | u_char *p = NULL, *signature = NULL; |
689 | char *alg = NULL; | 690 | char *alg = NULL; |
690 | size_t datlen, siglen, alglen; | 691 | size_t datlen, siglen, alglen; |
691 | int r, keyid, is_proof = 0; | 692 | int r, is_proof = 0; |
693 | u_int keyid; | ||
692 | const char proof_req[] = "hostkeys-prove-00@openssh.com"; | 694 | const char proof_req[] = "hostkeys-prove-00@openssh.com"; |
693 | 695 | ||
694 | debug3("%s", __func__); | 696 | debug3("%s", __func__); |
@@ -697,6 +699,8 @@ mm_answer_sign(int sock, Buffer *m) | |||
697 | (r = sshbuf_get_string(m, &p, &datlen)) != 0 || | 699 | (r = sshbuf_get_string(m, &p, &datlen)) != 0 || |
698 | (r = sshbuf_get_cstring(m, &alg, &alglen)) != 0) | 700 | (r = sshbuf_get_cstring(m, &alg, &alglen)) != 0) |
699 | fatal("%s: buffer error: %s", __func__, ssh_err(r)); | 701 | fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
702 | if (keyid > INT_MAX) | ||
703 | fatal("%s: invalid key ID", __func__); | ||
700 | 704 | ||
701 | /* | 705 | /* |
702 | * Supported KEX types use SHA1 (20 bytes), SHA256 (32 bytes), | 706 | * Supported KEX types use SHA1 (20 bytes), SHA256 (32 bytes), |
@@ -1289,7 +1293,8 @@ static int | |||
1289 | monitor_valid_userblob(u_char *data, u_int datalen) | 1293 | monitor_valid_userblob(u_char *data, u_int datalen) |
1290 | { | 1294 | { |
1291 | Buffer b; | 1295 | Buffer b; |
1292 | char *p, *userstyle; | 1296 | u_char *p; |
1297 | char *userstyle, *cp; | ||
1293 | u_int len; | 1298 | u_int len; |
1294 | int fail = 0; | 1299 | int fail = 0; |
1295 | 1300 | ||
@@ -1314,26 +1319,26 @@ monitor_valid_userblob(u_char *data, u_int datalen) | |||
1314 | } | 1319 | } |
1315 | if (buffer_get_char(&b) != SSH2_MSG_USERAUTH_REQUEST) | 1320 | if (buffer_get_char(&b) != SSH2_MSG_USERAUTH_REQUEST) |
1316 | fail++; | 1321 | fail++; |
1317 | p = buffer_get_cstring(&b, NULL); | 1322 | cp = buffer_get_cstring(&b, NULL); |
1318 | xasprintf(&userstyle, "%s%s%s", authctxt->user, | 1323 | xasprintf(&userstyle, "%s%s%s", authctxt->user, |
1319 | authctxt->style ? ":" : "", | 1324 | authctxt->style ? ":" : "", |
1320 | authctxt->style ? authctxt->style : ""); | 1325 | authctxt->style ? authctxt->style : ""); |
1321 | if (strcmp(userstyle, p) != 0) { | 1326 | if (strcmp(userstyle, cp) != 0) { |
1322 | logit("wrong user name passed to monitor: expected %s != %.100s", | 1327 | logit("wrong user name passed to monitor: " |
1323 | userstyle, p); | 1328 | "expected %s != %.100s", userstyle, cp); |
1324 | fail++; | 1329 | fail++; |
1325 | } | 1330 | } |
1326 | free(userstyle); | 1331 | free(userstyle); |
1327 | free(p); | 1332 | free(cp); |
1328 | buffer_skip_string(&b); | 1333 | buffer_skip_string(&b); |
1329 | if (datafellows & SSH_BUG_PKAUTH) { | 1334 | if (datafellows & SSH_BUG_PKAUTH) { |
1330 | if (!buffer_get_char(&b)) | 1335 | if (!buffer_get_char(&b)) |
1331 | fail++; | 1336 | fail++; |
1332 | } else { | 1337 | } else { |
1333 | p = buffer_get_cstring(&b, NULL); | 1338 | cp = buffer_get_cstring(&b, NULL); |
1334 | if (strcmp("publickey", p) != 0) | 1339 | if (strcmp("publickey", cp) != 0) |
1335 | fail++; | 1340 | fail++; |
1336 | free(p); | 1341 | free(cp); |
1337 | if (!buffer_get_char(&b)) | 1342 | if (!buffer_get_char(&b)) |
1338 | fail++; | 1343 | fail++; |
1339 | buffer_skip_string(&b); | 1344 | buffer_skip_string(&b); |