mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 14:36:16 +01:00
reverted raja's changes, since they leaked a struct passwd contents buffer
Sun Jan 24 10:33:30 1999 Tim Janik <timj@gtk.org> * gutils.c (g_get_any_init): reverted raja's changes, since they leaked a struct passwd contents buffer and for the rest mostly substituted a while loop with a bunch of gotos. restored the getpwuid() code to what we had after my recent clean ups ("Sat Jan 23 02:14:28 1999 Tim Janik"), module yosh's recent changes. to feature solaris behaviour of directly returning errno, we don't modify error anymore if it's > 0 and simply reset errno. don't reset g_home_dir for !NATIVE_WIN32 && !NATIVE_WIN32.
This commit is contained in:
parent
96cf177352
commit
c5fd4a3dc4
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Sun Jan 24 10:33:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): reverted raja's changes, since they leaked
|
||||||
|
a struct passwd contents buffer and for the rest mostly substituted a
|
||||||
|
while loop with a bunch of gotos.
|
||||||
|
restored the getpwuid() code to what we had after my recent clean ups
|
||||||
|
("Sat Jan 23 02:14:28 1999 Tim Janik"), module yosh's recent changes.
|
||||||
|
to feature solaris behaviour of directly returning errno, we don't
|
||||||
|
modify error anymore if it's > 0 and simply reset errno.
|
||||||
|
don't reset g_home_dir for !NATIVE_WIN32 && !NATIVE_WIN32.
|
||||||
|
|
||||||
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
* gutils.c
|
* gutils.c
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Jan 24 10:33:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): reverted raja's changes, since they leaked
|
||||||
|
a struct passwd contents buffer and for the rest mostly substituted a
|
||||||
|
while loop with a bunch of gotos.
|
||||||
|
restored the getpwuid() code to what we had after my recent clean ups
|
||||||
|
("Sat Jan 23 02:14:28 1999 Tim Janik"), module yosh's recent changes.
|
||||||
|
to feature solaris behaviour of directly returning errno, we don't
|
||||||
|
modify error anymore if it's > 0 and simply reset errno.
|
||||||
|
don't reset g_home_dir for !NATIVE_WIN32 && !NATIVE_WIN32.
|
||||||
|
|
||||||
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
* gutils.c
|
* gutils.c
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Jan 24 10:33:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): reverted raja's changes, since they leaked
|
||||||
|
a struct passwd contents buffer and for the rest mostly substituted a
|
||||||
|
while loop with a bunch of gotos.
|
||||||
|
restored the getpwuid() code to what we had after my recent clean ups
|
||||||
|
("Sat Jan 23 02:14:28 1999 Tim Janik"), module yosh's recent changes.
|
||||||
|
to feature solaris behaviour of directly returning errno, we don't
|
||||||
|
modify error anymore if it's > 0 and simply reset errno.
|
||||||
|
don't reset g_home_dir for !NATIVE_WIN32 && !NATIVE_WIN32.
|
||||||
|
|
||||||
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
* gutils.c
|
* gutils.c
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Jan 24 10:33:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): reverted raja's changes, since they leaked
|
||||||
|
a struct passwd contents buffer and for the rest mostly substituted a
|
||||||
|
while loop with a bunch of gotos.
|
||||||
|
restored the getpwuid() code to what we had after my recent clean ups
|
||||||
|
("Sat Jan 23 02:14:28 1999 Tim Janik"), module yosh's recent changes.
|
||||||
|
to feature solaris behaviour of directly returning errno, we don't
|
||||||
|
modify error anymore if it's > 0 and simply reset errno.
|
||||||
|
don't reset g_home_dir for !NATIVE_WIN32 && !NATIVE_WIN32.
|
||||||
|
|
||||||
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
* gutils.c
|
* gutils.c
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Jan 24 10:33:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): reverted raja's changes, since they leaked
|
||||||
|
a struct passwd contents buffer and for the rest mostly substituted a
|
||||||
|
while loop with a bunch of gotos.
|
||||||
|
restored the getpwuid() code to what we had after my recent clean ups
|
||||||
|
("Sat Jan 23 02:14:28 1999 Tim Janik"), module yosh's recent changes.
|
||||||
|
to feature solaris behaviour of directly returning errno, we don't
|
||||||
|
modify error anymore if it's > 0 and simply reset errno.
|
||||||
|
don't reset g_home_dir for !NATIVE_WIN32 && !NATIVE_WIN32.
|
||||||
|
|
||||||
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
* gutils.c
|
* gutils.c
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Jan 24 10:33:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): reverted raja's changes, since they leaked
|
||||||
|
a struct passwd contents buffer and for the rest mostly substituted a
|
||||||
|
while loop with a bunch of gotos.
|
||||||
|
restored the getpwuid() code to what we had after my recent clean ups
|
||||||
|
("Sat Jan 23 02:14:28 1999 Tim Janik"), module yosh's recent changes.
|
||||||
|
to feature solaris behaviour of directly returning errno, we don't
|
||||||
|
modify error anymore if it's > 0 and simply reset errno.
|
||||||
|
don't reset g_home_dir for !NATIVE_WIN32 && !NATIVE_WIN32.
|
||||||
|
|
||||||
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
* gutils.c
|
* gutils.c
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Jan 24 10:33:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): reverted raja's changes, since they leaked
|
||||||
|
a struct passwd contents buffer and for the rest mostly substituted a
|
||||||
|
while loop with a bunch of gotos.
|
||||||
|
restored the getpwuid() code to what we had after my recent clean ups
|
||||||
|
("Sat Jan 23 02:14:28 1999 Tim Janik"), module yosh's recent changes.
|
||||||
|
to feature solaris behaviour of directly returning errno, we don't
|
||||||
|
modify error anymore if it's > 0 and simply reset errno.
|
||||||
|
don't reset g_home_dir for !NATIVE_WIN32 && !NATIVE_WIN32.
|
||||||
|
|
||||||
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
* gutils.c
|
* gutils.c
|
||||||
|
@ -1,3 +1,14 @@
|
|||||||
|
Sun Jan 24 10:33:30 1999 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
|
* gutils.c (g_get_any_init): reverted raja's changes, since they leaked
|
||||||
|
a struct passwd contents buffer and for the rest mostly substituted a
|
||||||
|
while loop with a bunch of gotos.
|
||||||
|
restored the getpwuid() code to what we had after my recent clean ups
|
||||||
|
("Sat Jan 23 02:14:28 1999 Tim Janik"), module yosh's recent changes.
|
||||||
|
to feature solaris behaviour of directly returning errno, we don't
|
||||||
|
modify error anymore if it's > 0 and simply reset errno.
|
||||||
|
don't reset g_home_dir for !NATIVE_WIN32 && !NATIVE_WIN32.
|
||||||
|
|
||||||
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
1999-01-24 Raja R Harinath <harinath@cs.umn.edu>
|
||||||
|
|
||||||
* gutils.c
|
* gutils.c
|
||||||
|
@ -446,57 +446,26 @@ g_get_any_init (void)
|
|||||||
guint bufsize = 1; /* sizeof (struct passwd); */
|
guint bufsize = 1; /* sizeof (struct passwd); */
|
||||||
gint error;
|
gint error;
|
||||||
|
|
||||||
pw_retry:
|
do
|
||||||
|
{
|
||||||
|
g_free (buffer);
|
||||||
buffer = g_malloc (bufsize);
|
buffer = g_malloc (bufsize);
|
||||||
|
|
||||||
# ifdef HAVE_GETPWUID_R_POSIX
|
|
||||||
/* There appears to be some confusion about what the return
|
|
||||||
value should be, and whether errno is set or not.
|
|
||||||
So, we are careful about it. */
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
# ifdef HAVE_GETPWUID_R_POSIX
|
||||||
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
||||||
|
error = error < 1 ? errno : error;
|
||||||
if (error == 0)
|
|
||||||
goto pw_out;
|
|
||||||
|
|
||||||
/* Some kind of error.
|
|
||||||
|
|
||||||
SUSv2 says returned value is an error code; says nothing
|
|
||||||
about `errno'. GNU Libc says some non-null (sic) value and
|
|
||||||
errno is set. Either way, this code path is chosen.
|
|
||||||
|
|
||||||
If `errno' isn't changed, the return value contains the
|
|
||||||
error code (like ERANGE).
|
|
||||||
|
|
||||||
If `errno' is changed, then it must be right, irrespective
|
|
||||||
of whether the return value follows SUSv2 or not. */
|
|
||||||
if (errno != 0)
|
|
||||||
error = errno;
|
|
||||||
|
|
||||||
# else /* !HAVE_GETPWUID_R_POSIX */
|
# else /* !HAVE_GETPWUID_R_POSIX */
|
||||||
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
||||||
if (pw != NULL)
|
error = pw ? 0 : errno;
|
||||||
goto pw_out;
|
|
||||||
/* If it got here, there is an error. The `uid' should be
|
|
||||||
valid, so there must be something else wrong. */
|
|
||||||
error = errno;
|
|
||||||
# endif /* !HAVE_GETPWUID_R_POSIX */
|
# endif /* !HAVE_GETPWUID_R_POSIX */
|
||||||
|
|
||||||
/* If it came here, there's some kind of error. */
|
|
||||||
g_free (buffer);
|
|
||||||
|
|
||||||
if (error == ERANGE)
|
|
||||||
{
|
|
||||||
bufsize *= 2;
|
bufsize *= 2;
|
||||||
goto pw_retry;
|
|
||||||
}
|
}
|
||||||
|
while (error == ERANGE);
|
||||||
|
|
||||||
|
if (error)
|
||||||
g_warning ("getpwuid_r(): failed due to: %s", g_strerror (error));
|
g_warning ("getpwuid_r(): failed due to: %s", g_strerror (error));
|
||||||
/* Make any subsequent g_free (buffer) a no-op. */
|
|
||||||
buffer = NULL;
|
|
||||||
|
|
||||||
pw_out:
|
|
||||||
;
|
|
||||||
|
|
||||||
# else /* !HAVE_GETPWUID_R */
|
# else /* !HAVE_GETPWUID_R */
|
||||||
|
|
||||||
@ -529,11 +498,7 @@ g_get_any_init (void)
|
|||||||
g_real_name = g_strdup (buffer);
|
g_real_name = g_strdup (buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# else /* !NATIVE_WIN32 */
|
# endif /* NATIVE_WIN32 */
|
||||||
/* why are we forcefully setting g_home_dir to NULL here? */
|
|
||||||
g_free (g_home_dir);
|
|
||||||
g_home_dir = NULL;
|
|
||||||
# endif /* !NATIVE_WIN32 */
|
|
||||||
|
|
||||||
#endif /* !HAVE_PWD_H */
|
#endif /* !HAVE_PWD_H */
|
||||||
|
|
||||||
|
53
gutils.c
53
gutils.c
@ -446,57 +446,26 @@ g_get_any_init (void)
|
|||||||
guint bufsize = 1; /* sizeof (struct passwd); */
|
guint bufsize = 1; /* sizeof (struct passwd); */
|
||||||
gint error;
|
gint error;
|
||||||
|
|
||||||
pw_retry:
|
do
|
||||||
|
{
|
||||||
|
g_free (buffer);
|
||||||
buffer = g_malloc (bufsize);
|
buffer = g_malloc (bufsize);
|
||||||
|
|
||||||
# ifdef HAVE_GETPWUID_R_POSIX
|
|
||||||
/* There appears to be some confusion about what the return
|
|
||||||
value should be, and whether errno is set or not.
|
|
||||||
So, we are careful about it. */
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
# ifdef HAVE_GETPWUID_R_POSIX
|
||||||
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
|
||||||
|
error = error < 1 ? errno : error;
|
||||||
if (error == 0)
|
|
||||||
goto pw_out;
|
|
||||||
|
|
||||||
/* Some kind of error.
|
|
||||||
|
|
||||||
SUSv2 says returned value is an error code; says nothing
|
|
||||||
about `errno'. GNU Libc says some non-null (sic) value and
|
|
||||||
errno is set. Either way, this code path is chosen.
|
|
||||||
|
|
||||||
If `errno' isn't changed, the return value contains the
|
|
||||||
error code (like ERANGE).
|
|
||||||
|
|
||||||
If `errno' is changed, then it must be right, irrespective
|
|
||||||
of whether the return value follows SUSv2 or not. */
|
|
||||||
if (errno != 0)
|
|
||||||
error = errno;
|
|
||||||
|
|
||||||
# else /* !HAVE_GETPWUID_R_POSIX */
|
# else /* !HAVE_GETPWUID_R_POSIX */
|
||||||
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
|
||||||
if (pw != NULL)
|
error = pw ? 0 : errno;
|
||||||
goto pw_out;
|
|
||||||
/* If it got here, there is an error. The `uid' should be
|
|
||||||
valid, so there must be something else wrong. */
|
|
||||||
error = errno;
|
|
||||||
# endif /* !HAVE_GETPWUID_R_POSIX */
|
# endif /* !HAVE_GETPWUID_R_POSIX */
|
||||||
|
|
||||||
/* If it came here, there's some kind of error. */
|
|
||||||
g_free (buffer);
|
|
||||||
|
|
||||||
if (error == ERANGE)
|
|
||||||
{
|
|
||||||
bufsize *= 2;
|
bufsize *= 2;
|
||||||
goto pw_retry;
|
|
||||||
}
|
}
|
||||||
|
while (error == ERANGE);
|
||||||
|
|
||||||
|
if (error)
|
||||||
g_warning ("getpwuid_r(): failed due to: %s", g_strerror (error));
|
g_warning ("getpwuid_r(): failed due to: %s", g_strerror (error));
|
||||||
/* Make any subsequent g_free (buffer) a no-op. */
|
|
||||||
buffer = NULL;
|
|
||||||
|
|
||||||
pw_out:
|
|
||||||
;
|
|
||||||
|
|
||||||
# else /* !HAVE_GETPWUID_R */
|
# else /* !HAVE_GETPWUID_R */
|
||||||
|
|
||||||
@ -529,11 +498,7 @@ g_get_any_init (void)
|
|||||||
g_real_name = g_strdup (buffer);
|
g_real_name = g_strdup (buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# else /* !NATIVE_WIN32 */
|
# endif /* NATIVE_WIN32 */
|
||||||
/* why are we forcefully setting g_home_dir to NULL here? */
|
|
||||||
g_free (g_home_dir);
|
|
||||||
g_home_dir = NULL;
|
|
||||||
# endif /* !NATIVE_WIN32 */
|
|
||||||
|
|
||||||
#endif /* !HAVE_PWD_H */
|
#endif /* !HAVE_PWD_H */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user