aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1996-08-08 20:04:18 +0000
committerRichard M. Stallman1996-08-08 20:04:18 +0000
commit1155c45365ff4f15aa75e717233e880bc88d969d (patch)
treed422654a9f128bcad257740553d8c8f0f32ecd62 /src
parent9e5a48ce0b81993b10fdd2ddd49980c1c9ab19a7 (diff)
downloademacs-1155c45365ff4f15aa75e717233e880bc88d969d.tar.gz
emacs-1155c45365ff4f15aa75e717233e880bc88d969d.zip
(set_time_zone_rule): Don't put a string literal
"TZ=..." in environ.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 7e9a798c4e2..f705b34cbd0 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -936,6 +936,17 @@ If TZ is nil, use implementation-defined default time zone information.")
936 return Qnil; 936 return Qnil;
937} 937}
938 938
939/* These two values are known to load tz files in buggy implementations.
940 Their values shouldn't matter in non-buggy implementations.
941 We don't use string literals for these strings,
942 since if a string in the environment is in readonly
943 storage, it runs afoul of bugs in SVR4 and Solaris 2.3.
944 See Sun bugs 1113095 and 1114114, ``Timezone routines
945 improperly modify environment''. */
946
947static char set_time_zone_rule_tz1[] = "TZ=GMT0";
948static char set_time_zone_rule_tz2[] = "TZ=GMT1";
949
939/* Set the local time zone rule to TZSTRING. 950/* Set the local time zone rule to TZSTRING.
940 This allocates memory into `environ', which it is the caller's 951 This allocates memory into `environ', which it is the caller's
941 responsibility to free. */ 952 responsibility to free. */
@@ -986,17 +997,13 @@ set_time_zone_rule (tzstring)
986 not load a tz file, tzset can dump core (see Sun bug#1225179). 997 not load a tz file, tzset can dump core (see Sun bug#1225179).
987 The following code works around these bugs. */ 998 The following code works around these bugs. */
988 999
989 /* These two values are known to load tz files in buggy implementations.
990 Their values shouldn't matter in non-buggy implementations. */
991 char *tz1 = "TZ=GMT0";
992 char *tz2 = "TZ=GMT1";
993
994 if (tzstring) 1000 if (tzstring)
995 { 1001 {
996 /* Temporarily set TZ to a value that loads a tz file 1002 /* Temporarily set TZ to a value that loads a tz file
997 and that differs from tzstring. */ 1003 and that differs from tzstring. */
998 char *tz = *newenv; 1004 char *tz = *newenv;
999 *newenv = strcmp (tzstring, tz1 + 3) == 0 ? tz2 : tz1; 1005 *newenv = (strcmp (tzstring, set_time_zone_rule_tz1 + 3) == 0
1006 ? set_time_zone_rule_tz2 : set_time_zone_rule_tz1);
1000 tzset (); 1007 tzset ();
1001 *newenv = tz; 1008 *newenv = tz;
1002 } 1009 }
@@ -1004,10 +1011,10 @@ set_time_zone_rule (tzstring)
1004 { 1011 {
1005 /* The implied tzstring is unknown, so temporarily set TZ to 1012 /* The implied tzstring is unknown, so temporarily set TZ to
1006 two different values that each load a tz file. */ 1013 two different values that each load a tz file. */
1007 *to = tz1; 1014 *to = set_time_zone_rule_tz1;
1008 to[1] = 0; 1015 to[1] = 0;
1009 tzset (); 1016 tzset ();
1010 *to = tz2; 1017 *to = set_time_zone_rule_tz2;
1011 tzset (); 1018 tzset ();
1012 *to = 0; 1019 *to = 0;
1013 } 1020 }