Contents of /trunk/netkit-rsh/patches/netkit-rsh-0.17-max-arg.patch
Parent Directory | Revision Log
Revision 731 -
(show annotations)
(download)
Fri Dec 26 01:38:28 2008 UTC (15 years, 9 months ago) by niro
File size: 2145 byte(s)
Fri Dec 26 01:38:28 2008 UTC (15 years, 9 months ago) by niro
File size: 2145 byte(s)
fix compilation against glibc-2.8
1 | fix building when ARG_MAX is not defined |
2 | |
3 | patch by Tom-Steve Watzke |
4 | |
5 | http://bugs.gentoo.org/225341 |
6 | |
7 | --- netkit-rsh-0.17/rexecd/rexecd.c |
8 | +++ netkit-rsh-0.17/rexecd/rexecd.c |
9 | @@ -234,7 +234,8 @@ |
10 | static void |
11 | doit(struct sockaddr_in *fromp) |
12 | { |
13 | - char cmdbuf[ARG_MAX+1]; |
14 | + char *cmdbuf; |
15 | + int cmdbuflen; |
16 | char user[16], pass[16]; |
17 | struct passwd *pwd; |
18 | int s = -1; |
19 | @@ -253,6 +254,15 @@ |
20 | #endif |
21 | #endif /* USE_PAM */ |
22 | |
23 | + cmdbuflen = sysconf(_SC_ARG_MAX); |
24 | + if (cmdbuflen < _POSIX_ARG_MAX) |
25 | + cmdbuflen = _POSIX_ARG_MAX; |
26 | + cmdbuf = malloc(cmdbuflen); |
27 | + if (cmdbuf == NULL) { |
28 | + syslog(LOG_ERR, "unable to malloc(%i) for command buffer: %s", cmdbuflen, strerror(errno)); |
29 | + fatal("out of memory\n"); |
30 | + } |
31 | + |
32 | signal(SIGINT, SIG_DFL); |
33 | signal(SIGQUIT, SIG_DFL); |
34 | signal(SIGTERM, SIG_DFL); |
35 | @@ -302,7 +312,7 @@ |
36 | |
37 | getstr(user, sizeof(user), "username too long\n"); |
38 | getstr(pass, sizeof(pass), "password too long\n"); |
39 | - getstr(cmdbuf, sizeof(cmdbuf), "command too long\n"); |
40 | + getstr(cmdbuf, cmdbuflen, "command too long\n"); |
41 | #ifdef USE_PAM |
42 | #define PAM_BAIL if (pam_error != PAM_SUCCESS) { \ |
43 | pam_end(pamh, pam_error); exit(1); \ |
44 | --- netkit-rsh-0.17/rshd/rshd.c |
45 | +++ netkit-rsh-0.17/rshd/rshd.c |
46 | @@ -337,7 +337,8 @@ |
47 | static void |
48 | doit(struct sockaddr_in *fromp) |
49 | { |
50 | - char cmdbuf[ARG_MAX+1]; |
51 | + char *cmdbuf; |
52 | + int cmdbuflen; |
53 | const char *theshell, *shellname; |
54 | char locuser[16], remuser[16]; |
55 | struct passwd *pwd; |
56 | @@ -346,6 +347,15 @@ |
57 | u_short port; |
58 | int pv[2], pid, ifd; |
59 | |
60 | + cmdbuflen = sysconf(_SC_ARG_MAX); |
61 | + if (cmdbuflen < _POSIX_ARG_MAX) |
62 | + cmdbuflen = _POSIX_ARG_MAX; |
63 | + cmdbuf = malloc(cmdbuflen); |
64 | + if (cmdbuf == NULL) { |
65 | + syslog(LOG_ERR, "unable to malloc(%i) for command buffer: %s", cmdbuflen, strerror(errno)); |
66 | + exit(1); |
67 | + } |
68 | + |
69 | signal(SIGINT, SIG_DFL); |
70 | signal(SIGQUIT, SIG_DFL); |
71 | signal(SIGTERM, SIG_DFL); |
72 | @@ -382,7 +392,7 @@ |
73 | |
74 | getstr(remuser, sizeof(remuser), "remuser"); |
75 | getstr(locuser, sizeof(locuser), "locuser"); |
76 | - getstr(cmdbuf, sizeof(cmdbuf), "command"); |
77 | + getstr(cmdbuf, cmdbuflen, "command"); |
78 | if (!strcmp(locuser, "root")) paranoid = 1; |
79 | |
80 | hostname = findhostname(fromp, remuser, locuser, cmdbuf); |