Skip to content

Commit 2864e76

Browse files
author
Ulrich Drepper
committed
Update.
1999-11-09 Ulrich Drepper <[email protected]> * elf/dl-load.c (_dl_dst_count): Allow $ORIGIN to point to directory with the reference since this is as secure as using the object with the dependency. (_dl_dst_substitute): Likewise. * elf/dl-load.c (_dl_dst_count): Change strings in first two strncmp calls to allow reuse. (_dl_dst_substitute): Likewise. 1999-11-01 Arnold D. Robbins <[email protected]> * posix/regex.c (init_syntax_once): move below definition of ISALNUM etc., then use ISALNUM to init the table, so that the word ops will work if i18n'ed. (SYNTAX): And subscript with 0xFF for 8bit character sets. 1999-11-09 Andreas Jaeger <[email protected]> * sysdeps/unix/getlogin_r.c (getlogin_r): Sync with getlogin implementation for ttyname_r call; fix inverted condition; return ut_user. Closes PR libc/1438. 1999-11-09 Ulrich Drepper <[email protected]> * timezone/checktab.awk: Update from tzcode1999h. * timezone/africa: Update from tzdata1999i. * timezone/asia: Likewise. * timezone/australasia: Likewise. * timezone/backward: Likewise. * timezone/europe: Likewise. * timezone/northamerica: Likewise. * timezone/southamerica: Likewise. * timezone/iso3166.tab: Likewise. * timezone/zone.tab: Likewise. * sysdeps/unix/sysv/linux/bits/resource.h: Define values also as macros. Patch by [email protected] [PR libc/1439]. 1999-11-09 Andreas Jaeger <[email protected]> * posix/Makefile (tests): Added tst-getlogin. * posix/tst-getlogin.c: New file, contains simple tests for getlogin and getlogin_r. 1999-11-09 Andreas Schwab <[email protected]> * misc/syslog.c: For LOG_PERROR only append a newline if necessary.
1 parent f2b9733 commit 2864e76

File tree

19 files changed

+450
-326
lines changed

19 files changed

+450
-326
lines changed

ChangeLog

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,55 @@
1+
1999-11-09 Ulrich Drepper <[email protected]>
2+
3+
* elf/dl-load.c (_dl_dst_count): Allow $ORIGIN to point to
4+
directory with the reference since this is as secure as using the
5+
object with the dependency.
6+
(_dl_dst_substitute): Likewise.
7+
8+
* elf/dl-load.c (_dl_dst_count): Change strings in first two
9+
strncmp calls to allow reuse.
10+
(_dl_dst_substitute): Likewise.
11+
12+
1999-11-01 Arnold D. Robbins <[email protected]>
13+
14+
* posix/regex.c (init_syntax_once): move below definition of
15+
ISALNUM etc., then use ISALNUM to init the table, so that
16+
the word ops will work if i18n'ed.
17+
(SYNTAX): And subscript with 0xFF for 8bit character sets.
18+
19+
1999-11-09 Andreas Jaeger <[email protected]>
20+
21+
* sysdeps/unix/getlogin_r.c (getlogin_r): Sync with getlogin
22+
implementation for ttyname_r call; fix inverted condition; return
23+
ut_user. Closes PR libc/1438.
24+
25+
1999-11-09 Ulrich Drepper <[email protected]>
26+
27+
* timezone/checktab.awk: Update from tzcode1999h.
28+
* timezone/africa: Update from tzdata1999i.
29+
* timezone/asia: Likewise.
30+
* timezone/australasia: Likewise.
31+
* timezone/backward: Likewise.
32+
* timezone/europe: Likewise.
33+
* timezone/northamerica: Likewise.
34+
* timezone/southamerica: Likewise.
35+
* timezone/iso3166.tab: Likewise.
36+
* timezone/zone.tab: Likewise.
37+
38+
* sysdeps/unix/sysv/linux/bits/resource.h: Define values also as
39+
macros. Patch by [email protected] [PR libc/1439].
40+
41+
1999-11-09 Andreas Jaeger <[email protected]>
42+
43+
* posix/Makefile (tests): Added tst-getlogin.
44+
45+
* posix/tst-getlogin.c: New file, contains simple tests for
46+
getlogin and getlogin_r.
47+
48+
1999-11-09 Andreas Schwab <[email protected]>
49+
50+
* misc/syslog.c: For LOG_PERROR only append a newline if
51+
necessary.
52+
153
1999-11-08 Ulrich Drepper <[email protected]>
254

355
* elf/elf.h: Add STT_REGISTER, STT_HP_OPAQUE, and STT_ST_STUB

elf/dl-load.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,21 +149,31 @@ local_strdup (const char *s)
149149
size_t
150150
_dl_dst_count (const char *name, int is_path)
151151
{
152+
const char *const start = name;
152153
size_t cnt = 0;
153154

154155
do
155156
{
156157
size_t len = 1;
157158

158-
/* $ORIGIN is not expanded for SUID/GUID programs. */
159-
if ((((!__libc_enable_secure
160-
&& strncmp (&name[1], "ORIGIN", 6) == 0 && (len = 7) != 0)
161-
|| (strncmp (&name[1], "PLATFORM", 8) == 0 && (len = 9) != 0))
159+
/* $ORIGIN is not expanded for SUID/GUID programs.
160+
161+
Note that it is no bug that the strings in the first two `strncmp'
162+
calls are longer than the sequence which is actually tested. */
163+
if ((((strncmp (&name[1], "ORIGIN}", 6) == 0
164+
&& (!__libc_enable_secure
165+
|| ((name[7] == '\0' || (is_path && name[7] == ':'))
166+
&& (name == start || (is_path && name[-1] == ':'))))
167+
&& (len = 7) != 0)
168+
|| (strncmp (&name[1], "PLATFORM}", 8) == 0 && (len = 9) != 0))
162169
&& (name[len] == '\0' || name[len] == '/'
163170
|| (is_path && name[len] == ':')))
164171
|| (name[1] == '{'
165-
&& ((!__libc_enable_secure
166-
&& strncmp (&name[2], "ORIGIN}", 7) == 0 && (len = 9) != 0)
172+
&& ((strncmp (&name[2], "ORIGIN}", 7) == 0
173+
&& (!__libc_enable_secure
174+
|| ((name[9] == '\0' || (is_path && name[9] == ':'))
175+
&& (name == start || (is_path && name[-1] == ':'))))
176+
&& (len = 9) != 0)
167177
|| (strncmp (&name[2], "PLATFORM}", 9) == 0
168178
&& (len = 11) != 0))))
169179
++cnt;
@@ -180,6 +190,7 @@ char *
180190
_dl_dst_substitute (struct link_map *l, const char *name, char *result,
181191
int is_path)
182192
{
193+
const char *const start = name;
183194
char *last_elem, *wp;
184195

185196
/* Now fill the result path. While copying over the string we keep
@@ -195,8 +206,10 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
195206
const char *repl;
196207
size_t len;
197208

198-
if ((((strncmp (&name[1], "ORIGIN", 6) == 0 && (len = 7) != 0)
199-
|| (strncmp (&name[1], "PLATFORM", 8) == 0 && (len = 9) != 0))
209+
/* Note that it is no bug that the strings in the first two `strncmp'
210+
calls are longer than the sequence which is actually tested. */
211+
if ((((strncmp (&name[1], "ORIGIN}", 6) == 0 && (len = 7) != 0)
212+
|| (strncmp (&name[1], "PLATFORM}", 8) == 0 && (len = 9) != 0))
200213
&& (name[len] == '\0' || name[len] == '/'
201214
|| (is_path && name[len] == ':')))
202215
|| (name[1] == '{'
@@ -205,7 +218,12 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
205218
&& (len = 11) != 0))))
206219
{
207220
repl = ((len == 7 || name[2] == 'O')
208-
? (__libc_enable_secure ? NULL : l->l_origin)
221+
? (__libc_enable_secure
222+
&& ((name[len] != '\0'
223+
&& (!is_path || name[len] != ':'))
224+
|| (name != start
225+
&& (!is_path || name[-1] != ':')))
226+
? NULL : l->l_origin)
209227
: _dl_platform);
210228

211229
if (repl != NULL && repl != (const char *) -1)
@@ -259,7 +277,7 @@ expand_dynamic_string_token (struct link_map *l, const char *s)
259277
size_t total;
260278
char *result;
261279

262-
/* Determine the nubmer of DST elements. */
280+
/* Determine the number of DST elements. */
263281
cnt = DL_DST_COUNT (s, 1);
264282

265283
/* If we do not have to replace anything simply copy the string. */

manual/search.texi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,11 @@ elements.
475475
To remove a specific element matching @var{key} from the tree
476476
@code{tdelete} can be used. It locates the matching element using the
477477
same method as @code{tfind}. The corresponding element is then removed
478-
and the data if this tree node is returned by the function. If there is
479-
no matching entry in the tree nothing can be deleted and the function
480-
returns @code{NULL}.
478+
and a pointer to the parent of the deleted node is returned by the
479+
function. If there is no matching entry in the tree nothing can be
480+
deleted and the function returns @code{NULL}. If the root of the tree
481+
is deleted @code{tdelete} returns some unspecified value not equal to
482+
@code{NULL}.
481483
@end deftypefun
482484

483485
@comment search.h

misc/syslog.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,14 @@ vsyslog(pri, fmt, ap)
177177

178178
v->iov_base = buf + msgoff;
179179
v->iov_len = bufsize - msgoff;
180-
++v;
181-
v->iov_base = (char *) "\n";
182-
v->iov_len = 1;
183-
(void)__writev(STDERR_FILENO, iov, 2);
180+
/* Append a newline if necessary. */
181+
if (buf[bufsize - 1] != '\n')
182+
{
183+
++v;
184+
v->iov_base = (char *) "\n";
185+
v->iov_len = 1;
186+
}
187+
(void)__writev(STDERR_FILENO, iov, v - iov + 1);
184188
}
185189

186190
/* Prepare for multiple users. We have to take care: open and

posix/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ include ../Makeconfig
5757

5858
aux := init-posix environ
5959
tests := tstgetopt testfnm runtests runptests \
60-
tst-preadwrite test-vfork regexbug1
60+
tst-preadwrite test-vfork regexbug1 tst-getlogin
6161
ifeq (yes,$(build-shared))
6262
test-srcs := globtest
6363
tests += wordexp-test

posix/regex.c

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -164,46 +164,6 @@ char *realloc ();
164164
# define SWITCH_ENUM_CAST(x) (x)
165165
# endif
166166

167-
/* How many characters in the character set. */
168-
# define CHAR_SET_SIZE 256
169-
170-
# ifdef SYNTAX_TABLE
171-
172-
extern char *re_syntax_table;
173-
174-
# else /* not SYNTAX_TABLE */
175-
176-
static char re_syntax_table[CHAR_SET_SIZE];
177-
178-
static void
179-
init_syntax_once ()
180-
{
181-
register int c;
182-
static int done;
183-
184-
if (done)
185-
return;
186-
187-
bzero (re_syntax_table, sizeof re_syntax_table);
188-
189-
for (c = 'a'; c <= 'z'; c++)
190-
re_syntax_table[c] = Sword;
191-
192-
for (c = 'A'; c <= 'Z'; c++)
193-
re_syntax_table[c] = Sword;
194-
195-
for (c = '0'; c <= '9'; c++)
196-
re_syntax_table[c] = Sword;
197-
198-
re_syntax_table['_'] = Sword;
199-
200-
done = 1;
201-
}
202-
203-
# endif /* not SYNTAX_TABLE */
204-
205-
# define SYNTAX(c) re_syntax_table[c]
206-
207167
#endif /* not emacs */
208168

209169
/* Get the interface, including the syntax bits. */
@@ -276,6 +236,43 @@ init_syntax_once ()
276236
# define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128)
277237
#endif
278238

239+
#ifndef emacs
240+
/* How many characters in the character set. */
241+
# define CHAR_SET_SIZE 256
242+
243+
# ifdef SYNTAX_TABLE
244+
245+
extern char *re_syntax_table;
246+
247+
# else /* not SYNTAX_TABLE */
248+
249+
static char re_syntax_table[CHAR_SET_SIZE];
250+
251+
static void
252+
init_syntax_once ()
253+
{
254+
register int c;
255+
static int done = 0;
256+
257+
if (done)
258+
return;
259+
bzero (re_syntax_table, sizeof re_syntax_table);
260+
261+
for (c = 0; c < CHAR_SET_SIZE; ++c)
262+
if (ISALNUM (c))
263+
re_syntax_table[c] = Sword;
264+
265+
re_syntax_table['_'] = Sword;
266+
267+
done = 1;
268+
}
269+
270+
# endif /* not SYNTAX_TABLE */
271+
272+
# define SYNTAX(c) re_syntax_table[((c) & 0xFF)]
273+
274+
#endif /* emacs */
275+
279276
/* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we
280277
use `alloca' instead of `malloc'. This is because using malloc in
281278
re_search* or re_match* could cause memory leaks when C-g is used in

posix/tst-getlogin.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* Copyright (C) 1999 Free Software Foundation, Inc.
2+
This file is part of the GNU C Library.
3+
4+
The GNU C Library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Library General Public License as
6+
published by the Free Software Foundation; either version 2 of the
7+
License, or (at your option) any later version.
8+
9+
The GNU C Library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
Library General Public License for more details.
13+
14+
You should have received a copy of the GNU Library General Public
15+
License along with the GNU C Library; see the file COPYING.LIB. If not,
16+
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17+
Boston, MA 02111-1307, USA. */
18+
19+
#include <unistd.h>
20+
#include <stdio.h>
21+
#include <string.h>
22+
23+
int
24+
main (void)
25+
{
26+
char *login;
27+
int errors = 0;
28+
29+
login = getlogin ();
30+
if (login == NULL)
31+
puts ("getlogin returned NULL, no further tests");
32+
else
33+
{
34+
char name[1024];
35+
int ret;
36+
37+
printf ("getlogin returned: `%s'\n", login);
38+
39+
ret = getlogin_r (name, sizeof (name));
40+
if (ret == 0)
41+
{
42+
printf ("getlogin_r returned: `%s'\n", name);
43+
if (strcmp (name, login) != 0)
44+
{
45+
puts ("Error: getlogin and getlogin_r returned different names");
46+
++errors;
47+
}
48+
}
49+
else
50+
{
51+
printf ("Error: getlogin_r returned: %d (%s)\n",
52+
ret, strerror (ret));
53+
++errors;
54+
}
55+
}
56+
57+
return errors != 0;
58+
}

sysdeps/unix/getlogin_r.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@ getlogin_r (name, name_len)
4040
int result = 0;
4141
struct utmp *ut, line, buffer;
4242

43-
{
44-
int d = __open ("/dev/tty", 0);
45-
if (d < 0)
46-
return errno;
43+
/* Get name of tty connected to fd 0. Return if not a tty or
44+
if fd 0 isn't open. Note that a lot of documentation says that
45+
getlogin() is based on the controlling terminal---what they
46+
really mean is "the terminal connected to standard input". The
47+
getlogin() implementation of DEC Unix, SunOS, Solaris, HP-UX all
48+
return NULL if fd 0 has been closed, so this is the compatible
49+
thing to do. Note that ttyname(open("/dev/tty")) on those
50+
systems returns /dev/tty, so that is not a possible solution for
51+
getlogin(). */
4752

48-
result = __ttyname_r (d, real_tty_path, sizeof (tty_pathname));
49-
(void) __close (d);
50-
51-
if (result != 0)
52-
{
53-
__set_errno (result);
54-
return result;
55-
}
56-
}
53+
result = __ttyname_r (0, real_tty_path, sizeof (tty_pathname));
54+
55+
if (result != 0)
56+
return result;
5757

5858
real_tty_path += 5; /* Remove "/dev/". */
5959

@@ -69,16 +69,16 @@ getlogin_r (name, name_len)
6969
}
7070
else
7171
{
72-
size_t needed = strlen (ut->ut_line) + 1;
72+
size_t needed = strlen (ut->ut_user) + 1;
7373

74-
if (needed < name_len)
74+
if (needed > name_len)
7575
{
7676
__set_errno (ERANGE);
7777
result = ERANGE;
7878
}
7979
else
8080
{
81-
memcpy (name, ut->ut_line, needed);
81+
memcpy (name, ut->ut_user, needed);
8282
result = 0;
8383
}
8484
}

sysdeps/unix/sysv/linux/bits/resource.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ struct rusage
219219
enum __priority_which
220220
{
221221
PRIO_PROCESS = 0, /* WHO is a process ID. */
222+
#define PRIO_PROCESS PRIO_PROCESS
222223
PRIO_PGRP = 1, /* WHO is a process group ID. */
224+
#define PRIO_PGRP PRIO_PGRP
223225
PRIO_USER = 2 /* WHO is a user ID. */
226+
#define PRIO_USER PRIO_USER
224227
};

0 commit comments

Comments
 (0)