mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc 2.12.7.2
Fixed a segfault when getpwuid() returned NULL during initialization. Thanks goes to baratharon GitHub user for reporting this issue.
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -15,7 +15,8 @@ The following are the changes from calc version 2.12.7.1 to date:
|
|||||||
\t tab byte 0x09 in ASCII encoding
|
\t tab byte 0x09 in ASCII encoding
|
||||||
\v vertical tab byte 0x0b in ASCII encoding
|
\v vertical tab byte 0x0b in ASCII encoding
|
||||||
|
|
||||||
Sorry!
|
Fixed a segfault when getpwuid() returned NULL during initialization.
|
||||||
|
Thanks goes to baratharon GitHub user for reporting this issue.
|
||||||
|
|
||||||
|
|
||||||
The following are the changes from calc version 2.12.6.10: to 2.12.7.0:
|
The following are the changes from calc version 2.12.6.10: to 2.12.7.0:
|
||||||
|
@@ -1054,7 +1054,7 @@ EXT=
|
|||||||
|
|
||||||
# The default calc versions
|
# The default calc versions
|
||||||
#
|
#
|
||||||
VERSION= 2.12.7.1
|
VERSION= 2.12.7.2
|
||||||
|
|
||||||
# Names of shared libraries with versions
|
# Names of shared libraries with versions
|
||||||
#
|
#
|
||||||
|
@@ -348,7 +348,7 @@ EXT=
|
|||||||
|
|
||||||
# The default calc versions
|
# The default calc versions
|
||||||
#
|
#
|
||||||
VERSION= 2.12.7.1
|
VERSION= 2.12.7.2
|
||||||
|
|
||||||
# Names of shared libraries with versions
|
# Names of shared libraries with versions
|
||||||
#
|
#
|
||||||
|
@@ -348,7 +348,7 @@ EXT=
|
|||||||
|
|
||||||
# The default calc versions
|
# The default calc versions
|
||||||
#
|
#
|
||||||
VERSION= 2.12.7.1
|
VERSION= 2.12.7.2
|
||||||
|
|
||||||
# Names of shared libraries with versions
|
# Names of shared libraries with versions
|
||||||
#
|
#
|
||||||
|
33
lib_calc.c
33
lib_calc.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* lib_calc - calc link library initialization and shutdown routines
|
* lib_calc - calc link library initialization and shutdown routines
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2007 Landon Curt Noll
|
* Copyright (C) 1999-2007,2018 Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Calc is open software; you can redistribute it and/or modify it under
|
* Calc is open software; you can redistribute it and/or modify it under
|
||||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -504,22 +504,35 @@ initenv(void)
|
|||||||
home = (c ? strdup(c) : NULL);
|
home = (c ? strdup(c) : NULL);
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
if (home == NULL || home[0] == '\0') {
|
if (home == NULL || home[0] == '\0') {
|
||||||
|
/* free home if it was previously allocated, but empty */
|
||||||
|
if (home != NULL) {
|
||||||
|
free(home);
|
||||||
|
}
|
||||||
/* just assume . is home if all else fails */
|
/* just assume . is home if all else fails */
|
||||||
home = ".";
|
home = strdup(".");
|
||||||
}
|
}
|
||||||
#else /* Windoz free systems */
|
#else /* Windoz free systems */
|
||||||
if (home == NULL || home[0] == '\0') {
|
if (home == NULL || home[0] == '\0') {
|
||||||
size_t pw_dir_len;
|
/* free home if it was previously allocated, but empty */
|
||||||
ent = (struct passwd *)getpwuid(geteuid());
|
if (home != NULL) {
|
||||||
if (ent == NULL) {
|
free(home);
|
||||||
/* just assume . is home if all else fails */
|
}
|
||||||
home = ".";
|
/* try using the home directory of current effective UID from password file */
|
||||||
|
ent = (struct passwd *)getpwuid(geteuid());
|
||||||
|
if (ent == NULL || ent->pw_dir == NULL || ent->pw_dir[0] == '\0') {
|
||||||
|
/* just assume . is home if all else fails */
|
||||||
|
home = strdup(".");
|
||||||
|
} else {
|
||||||
|
/* use home directory of current effective UID from password file */
|
||||||
|
home = strdup(ent->pw_dir);
|
||||||
}
|
}
|
||||||
pw_dir_len = strlen(ent->pw_dir);
|
|
||||||
home = (char *)malloc(pw_dir_len+1);
|
|
||||||
strncpy(home, ent->pw_dir, pw_dir_len+1);
|
|
||||||
}
|
}
|
||||||
#endif /* Windoz free systems */
|
#endif /* Windoz free systems */
|
||||||
|
/* paranoia */
|
||||||
|
if (home == NULL) {
|
||||||
|
math_error("Unable to allocate string for $HOME");
|
||||||
|
/*NOTREACHED*/
|
||||||
|
}
|
||||||
|
|
||||||
/* determine the $PAGER value */
|
/* determine the $PAGER value */
|
||||||
c = (no_env ? NULL : getenv(PAGER));
|
c = (no_env ? NULL : getenv(PAGER));
|
||||||
|
@@ -45,7 +45,7 @@ static char *program;
|
|||||||
#define MAJOR_VER 2 /* major library version */
|
#define MAJOR_VER 2 /* major library version */
|
||||||
#define MINOR_VER 12 /* minor library version */
|
#define MINOR_VER 12 /* minor library version */
|
||||||
#define MAJOR_PATCH 7 /* major software level under library version */
|
#define MAJOR_PATCH 7 /* major software level under library version */
|
||||||
#define MINOR_PATCH 1 /* minor software level or 0 if not patched */
|
#define MINOR_PATCH 2 /* minor software level or 0 if not patched */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user