summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorderaadt@openbsd.org <deraadt@openbsd.org>2015-01-16 06:40:12 +0000
committerDamien Miller <djm@mindrot.org>2015-01-16 18:24:48 +1100
commit2ae4f337b2a5fb2841b6b0053b49496fef844d1c (patch)
tree59aac6ef59be3975eb3a1251abb0be330c008cdd
parent3c4726f4c24118e8f1bb80bf75f1456c76df072c (diff)
upstream commit
Replace <sys/param.h> with <limits.h> and other less dirty headers where possible. Annotate <sys/param.h> lines with their current reasons. Switch to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where sensible to avoid pulling in the pollution. These are the files confirmed through binary verification. ok guenther, millert, doug (helped with the verification protocol)
-rw-r--r--atomicio.c3
-rw-r--r--misc.c6
-rw-r--r--readconf.c3
-rw-r--r--scp.c7
-rw-r--r--servconf.c5
-rw-r--r--session.c5
-rw-r--r--ssh-add.c6
-rw-r--r--ssh-agent.c8
-rw-r--r--ssh-keygen.c12
-rw-r--r--sshkey.c5
-rw-r--r--sshlogin.c4
-rw-r--r--uidswap.c4
-rw-r--r--xmalloc.c4
13 files changed, 40 insertions, 32 deletions
diff --git a/atomicio.c b/atomicio.c
index 2bac36c91..b1ec234f5 100644
--- a/atomicio.c
+++ b/atomicio.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: atomicio.c,v 1.26 2010/09/22 22:58:51 djm Exp $ */ 1/* $OpenBSD: atomicio.c,v 1.27 2015/01/16 06:40:12 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2006 Damien Miller. All rights reserved. 3 * Copyright (c) 2006 Damien Miller. All rights reserved.
4 * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved. 4 * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved.
@@ -41,6 +41,7 @@
41#endif 41#endif
42#include <string.h> 42#include <string.h>
43#include <unistd.h> 43#include <unistd.h>
44#include <limits.h>
44 45
45#include "atomicio.h" 46#include "atomicio.h"
46 47
diff --git a/misc.c b/misc.c
index 2f11de40f..38af3dfe3 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.95 2014/10/24 02:01:20 lteo Exp $ */ 1/* $OpenBSD: misc.c,v 1.96 2015/01/16 06:40:12 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved. 4 * Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -30,8 +30,8 @@
30#include <sys/ioctl.h> 30#include <sys/ioctl.h>
31#include <sys/socket.h> 31#include <sys/socket.h>
32#include <sys/un.h> 32#include <sys/un.h>
33#include <sys/param.h>
34 33
34#include <limits.h>
35#include <stdarg.h> 35#include <stdarg.h>
36#include <stdio.h> 36#include <stdio.h>
37#include <stdlib.h> 37#include <stdlib.h>
@@ -551,7 +551,7 @@ tilde_expand_filename(const char *filename, uid_t uid)
551 if (path != NULL) 551 if (path != NULL)
552 filename = path + 1; 552 filename = path + 1;
553 553
554 if (xasprintf(&ret, "%s%s%s", pw->pw_dir, sep, filename) >= MAXPATHLEN) 554 if (xasprintf(&ret, "%s%s%s", pw->pw_dir, sep, filename) >= PATH_MAX)
555 fatal("tilde_expand_filename: Path too long"); 555 fatal("tilde_expand_filename: Path too long");
556 556
557 return (ret); 557 return (ret);
diff --git a/readconf.c b/readconf.c
index a122d176d..cb61a5af0 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.227 2015/01/15 09:40:00 djm Exp $ */ 1/* $OpenBSD: readconf.c,v 1.228 2015/01/16 06:40:12 deraadt Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -28,6 +28,7 @@
28#include <ctype.h> 28#include <ctype.h>
29#include <errno.h> 29#include <errno.h>
30#include <fcntl.h> 30#include <fcntl.h>
31#include <limits.h>
31#include <netdb.h> 32#include <netdb.h>
32#ifdef HAVE_PATHS_H 33#ifdef HAVE_PATHS_H
33# include <paths.h> 34# include <paths.h>
diff --git a/scp.c b/scp.c
index 1ec3b7087..887b014b8 100644
--- a/scp.c
+++ b/scp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: scp.c,v 1.180 2014/06/24 02:21:01 djm Exp $ */ 1/* $OpenBSD: scp.c,v 1.181 2015/01/16 06:40:12 deraadt Exp $ */
2/* 2/*
3 * scp - secure remote copy. This is basically patched BSD rcp which 3 * scp - secure remote copy. This is basically patched BSD rcp which
4 * uses ssh to do the data transfer (instead of using rcmd). 4 * uses ssh to do the data transfer (instead of using rcmd).
@@ -95,6 +95,7 @@
95#include <dirent.h> 95#include <dirent.h>
96#include <errno.h> 96#include <errno.h>
97#include <fcntl.h> 97#include <fcntl.h>
98#include <limits.h>
98#include <pwd.h> 99#include <pwd.h>
99#include <signal.h> 100#include <signal.h>
100#include <stdarg.h> 101#include <stdarg.h>
@@ -749,7 +750,7 @@ source(int argc, char **argv)
749 off_t i, statbytes; 750 off_t i, statbytes;
750 size_t amt, nr; 751 size_t amt, nr;
751 int fd = -1, haderr, indx; 752 int fd = -1, haderr, indx;
752 char *last, *name, buf[2048], encname[MAXPATHLEN]; 753 char *last, *name, buf[2048], encname[PATH_MAX];
753 int len; 754 int len;
754 755
755 for (indx = 0; indx < argc; ++indx) { 756 for (indx = 0; indx < argc; ++indx) {
@@ -858,7 +859,7 @@ rsource(char *name, struct stat *statp)
858{ 859{
859 DIR *dirp; 860 DIR *dirp;
860 struct dirent *dp; 861 struct dirent *dp;
861 char *last, *vect[1], path[MAXPATHLEN]; 862 char *last, *vect[1], path[PATH_MAX];
862 863
863 if (!(dirp = opendir(name))) { 864 if (!(dirp = opendir(name))) {
864 run_err("%s: %s", name, strerror(errno)); 865 run_err("%s: %s", name, strerror(errno));
diff --git a/servconf.c b/servconf.c
index 1b6bdb4af..475076bf2 100644
--- a/servconf.c
+++ b/servconf.c
@@ -1,5 +1,5 @@
1 1
2/* $OpenBSD: servconf.c,v 1.258 2015/01/13 07:39:19 djm Exp $ */ 2/* $OpenBSD: servconf.c,v 1.259 2015/01/16 06:40:12 deraadt Exp $ */
3/* 3/*
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * All rights reserved 5 * All rights reserved
@@ -28,6 +28,7 @@
28#include <string.h> 28#include <string.h>
29#include <signal.h> 29#include <signal.h>
30#include <unistd.h> 30#include <unistd.h>
31#include <limits.h>
31#include <stdarg.h> 32#include <stdarg.h>
32#include <errno.h> 33#include <errno.h>
33#ifdef HAVE_UTIL_H 34#ifdef HAVE_UTIL_H
@@ -571,7 +572,7 @@ parse_token(const char *cp, const char *filename,
571char * 572char *
572derelativise_path(const char *path) 573derelativise_path(const char *path)
573{ 574{
574 char *expanded, *ret, cwd[MAXPATHLEN]; 575 char *expanded, *ret, cwd[PATH_MAX];
575 576
576 if (strcasecmp(path, "none") == 0) 577 if (strcasecmp(path, "none") == 0)
577 return xstrdup("none"); 578 return xstrdup("none");
diff --git a/session.c b/session.c
index fbb921bea..54bac36a8 100644
--- a/session.c
+++ b/session.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: session.c,v 1.276 2015/01/14 20:05:27 djm Exp $ */ 1/* $OpenBSD: session.c,v 1.277 2015/01/16 06:40:12 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved 4 * All rights reserved
@@ -60,6 +60,7 @@
60#include <stdlib.h> 60#include <stdlib.h>
61#include <string.h> 61#include <string.h>
62#include <unistd.h> 62#include <unistd.h>
63#include <limits.h>
63 64
64#include "openbsd-compat/sys-queue.h" 65#include "openbsd-compat/sys-queue.h"
65#include "xmalloc.h" 66#include "xmalloc.h"
@@ -1437,7 +1438,7 @@ static void
1437safely_chroot(const char *path, uid_t uid) 1438safely_chroot(const char *path, uid_t uid)
1438{ 1439{
1439 const char *cp; 1440 const char *cp;
1440 char component[MAXPATHLEN]; 1441 char component[PATH_MAX];
1441 struct stat st; 1442 struct stat st;
1442 1443
1443 if (*path != '/') 1444 if (*path != '/')
diff --git a/ssh-add.c b/ssh-add.c
index 32add8807..5ac51088f 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-add.c,v 1.116 2015/01/14 20:05:27 djm Exp $ */ 1/* $OpenBSD: ssh-add.c,v 1.117 2015/01/16 06:40:12 deraadt Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -39,7 +39,6 @@
39 39
40#include <sys/types.h> 40#include <sys/types.h>
41#include <sys/stat.h> 41#include <sys/stat.h>
42#include <sys/param.h>
43 42
44#include <openssl/evp.h> 43#include <openssl/evp.h>
45#include "openbsd-compat/openssl-compat.h" 44#include "openbsd-compat/openssl-compat.h"
@@ -52,6 +51,7 @@
52#include <stdlib.h> 51#include <stdlib.h>
53#include <string.h> 52#include <string.h>
54#include <unistd.h> 53#include <unistd.h>
54#include <limits.h>
55 55
56#include "xmalloc.h" 56#include "xmalloc.h"
57#include "ssh.h" 57#include "ssh.h"
@@ -573,7 +573,7 @@ main(int argc, char **argv)
573 goto done; 573 goto done;
574 } 574 }
575 if (argc == 0) { 575 if (argc == 0) {
576 char buf[MAXPATHLEN]; 576 char buf[PATH_MAX];
577 struct passwd *pw; 577 struct passwd *pw;
578 struct stat st; 578 struct stat st;
579 int count = 0; 579 int count = 0;
diff --git a/ssh-agent.c b/ssh-agent.c
index 24500d9d6..ba8d020ad 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-agent.c,v 1.195 2015/01/14 19:33:41 djm Exp $ */ 1/* $OpenBSD: ssh-agent.c,v 1.196 2015/01/16 06:40:12 deraadt Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -36,6 +36,7 @@
36 36
37#include "includes.h" 37#include "includes.h"
38 38
39#include <sys/param.h> /* MIN MAX */
39#include <sys/types.h> 40#include <sys/types.h>
40#include <sys/param.h> 41#include <sys/param.h>
41#include <sys/resource.h> 42#include <sys/resource.h>
@@ -56,6 +57,7 @@
56 57
57#include <errno.h> 58#include <errno.h>
58#include <fcntl.h> 59#include <fcntl.h>
60#include <limits.h>
59#ifdef HAVE_PATHS_H 61#ifdef HAVE_PATHS_H
60# include <paths.h> 62# include <paths.h>
61#endif 63#endif
@@ -134,8 +136,8 @@ time_t parent_alive_interval = 0;
134pid_t cleanup_pid = 0; 136pid_t cleanup_pid = 0;
135 137
136/* pathname and directory for AUTH_SOCKET */ 138/* pathname and directory for AUTH_SOCKET */
137char socket_name[MAXPATHLEN]; 139char socket_name[PATH_MAX];
138char socket_dir[MAXPATHLEN]; 140char socket_dir[PATH_MAX];
139 141
140/* locking */ 142/* locking */
141int locked = 0; 143int locked = 0;
diff --git a/ssh-keygen.c b/ssh-keygen.c
index c8b05e079..9f6106d47 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-keygen.c,v 1.252 2015/01/15 09:40:00 djm Exp $ */ 1/* $OpenBSD: ssh-keygen.c,v 1.253 2015/01/16 06:40:12 deraadt Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -17,7 +17,6 @@
17#include <sys/types.h> 17#include <sys/types.h>
18#include <sys/socket.h> 18#include <sys/socket.h>
19#include <sys/stat.h> 19#include <sys/stat.h>
20#include <sys/param.h>
21 20
22#ifdef WITH_OPENSSL 21#ifdef WITH_OPENSSL
23#include <openssl/evp.h> 22#include <openssl/evp.h>
@@ -37,6 +36,7 @@
37#include <stdlib.h> 36#include <stdlib.h>
38#include <string.h> 37#include <string.h>
39#include <unistd.h> 38#include <unistd.h>
39#include <limits.h>
40 40
41#include "xmalloc.h" 41#include "xmalloc.h"
42#include "sshkey.h" 42#include "sshkey.h"
@@ -1065,7 +1065,7 @@ do_known_hosts(struct passwd *pw, const char *name)
1065 FILE *in, *out = stdout; 1065 FILE *in, *out = stdout;
1066 struct sshkey *pub; 1066 struct sshkey *pub;
1067 char *cp, *cp2, *kp, *kp2; 1067 char *cp, *cp2, *kp, *kp2;
1068 char line[16*1024], tmp[MAXPATHLEN], old[MAXPATHLEN]; 1068 char line[16*1024], tmp[PATH_MAX], old[PATH_MAX];
1069 int c, skip = 0, inplace = 0, num = 0, invalid = 0, has_unhashed = 0; 1069 int c, skip = 0, inplace = 0, num = 0, invalid = 0, has_unhashed = 0;
1070 int r, ca, revoked; 1070 int r, ca, revoked;
1071 int found_key = 0; 1071 int found_key = 0;
@@ -2291,9 +2291,9 @@ usage(void)
2291int 2291int
2292main(int argc, char **argv) 2292main(int argc, char **argv)
2293{ 2293{
2294 char dotsshdir[MAXPATHLEN], comment[1024], *passphrase1, *passphrase2; 2294 char dotsshdir[PATH_MAX], comment[1024], *passphrase1, *passphrase2;
2295 char *checkpoint = NULL; 2295 char *checkpoint = NULL;
2296 char out_file[MAXPATHLEN], *rr_hostname = NULL, *ep; 2296 char out_file[PATH_MAX], *rr_hostname = NULL, *ep;
2297 struct sshkey *private, *public; 2297 struct sshkey *private, *public;
2298 struct passwd *pw; 2298 struct passwd *pw;
2299 struct stat st; 2299 struct stat st;
@@ -2513,7 +2513,7 @@ main(int argc, char **argv)
2513 fatal("Output filename too long"); 2513 fatal("Output filename too long");
2514 break; 2514 break;
2515 case 'K': 2515 case 'K':
2516 if (strlen(optarg) >= MAXPATHLEN) 2516 if (strlen(optarg) >= PATH_MAX)
2517 fatal("Checkpoint filename too long"); 2517 fatal("Checkpoint filename too long");
2518 checkpoint = xstrdup(optarg); 2518 checkpoint = xstrdup(optarg);
2519 break; 2519 break;
diff --git a/sshkey.c b/sshkey.c
index add9f2b73..99c53bbcc 100644
--- a/sshkey.c
+++ b/sshkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshkey.c,v 1.12 2015/01/14 10:46:28 djm Exp $ */ 1/* $OpenBSD: sshkey.c,v 1.13 2015/01/16 06:40:12 deraadt Exp $ */
2/* 2/*
3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2008 Alexander von Gernler. All rights reserved. 4 * Copyright (c) 2008 Alexander von Gernler. All rights reserved.
@@ -27,7 +27,7 @@
27 27
28#include "includes.h" 28#include "includes.h"
29 29
30#include <sys/param.h> 30#include <sys/param.h> /* MIN MAX */
31#include <sys/types.h> 31#include <sys/types.h>
32#include <netinet/in.h> 32#include <netinet/in.h>
33 33
@@ -40,6 +40,7 @@
40#include "crypto_api.h" 40#include "crypto_api.h"
41 41
42#include <errno.h> 42#include <errno.h>
43#include <limits.h>
43#include <stdio.h> 44#include <stdio.h>
44#include <string.h> 45#include <string.h>
45#include <resolv.h> 46#include <resolv.h>
diff --git a/sshlogin.c b/sshlogin.c
index 7b951c844..3313ac998 100644
--- a/sshlogin.c
+++ b/sshlogin.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshlogin.c,v 1.29 2014/07/15 15:54:14 millert Exp $ */ 1/* $OpenBSD: sshlogin.c,v 1.30 2015/01/16 06:40:12 deraadt Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -42,7 +42,7 @@
42#include "includes.h" 42#include "includes.h"
43 43
44#include <sys/types.h> 44#include <sys/types.h>
45#include <sys/param.h> 45#include <sys/param.h> /* MAXHOSTNAMELEN */
46#include <sys/socket.h> 46#include <sys/socket.h>
47 47
48#include <netinet/in.h> 48#include <netinet/in.h>
diff --git a/uidswap.c b/uidswap.c
index 1f09d5887..c339283af 100644
--- a/uidswap.c
+++ b/uidswap.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: uidswap.c,v 1.36 2013/11/08 11:15:19 dtucker Exp $ */ 1/* $OpenBSD: uidswap.c,v 1.37 2015/01/16 06:40:12 deraadt Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -14,11 +14,11 @@
14 14
15#include "includes.h" 15#include "includes.h"
16 16
17#include <sys/param.h>
18#include <errno.h> 17#include <errno.h>
19#include <pwd.h> 18#include <pwd.h>
20#include <string.h> 19#include <string.h>
21#include <unistd.h> 20#include <unistd.h>
21#include <limits.h>
22#include <stdarg.h> 22#include <stdarg.h>
23#include <stdlib.h> 23#include <stdlib.h>
24 24
diff --git a/xmalloc.c b/xmalloc.c
index 2f1cd2306..0a9f282ae 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: xmalloc.c,v 1.29 2014/01/04 17:50:55 tedu Exp $ */ 1/* $OpenBSD: xmalloc.c,v 1.30 2015/01/16 06:40:12 deraadt Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -15,11 +15,11 @@
15 15
16#include "includes.h" 16#include "includes.h"
17 17
18#include <sys/param.h>
19#include <stdarg.h> 18#include <stdarg.h>
20#include <stdio.h> 19#include <stdio.h>
21#include <stdlib.h> 20#include <stdlib.h>
22#include <string.h> 21#include <string.h>
22#include <limits.h>
23 23
24#include "xmalloc.h" 24#include "xmalloc.h"
25#include "log.h" 25#include "log.h"