[CORE (21.4)] Fix stack overflow in mapconcat
18 years
Steve Youngs
Hi Vin!
This patch fixes a stack overflow bug in mapconcat. The recipe to
reproduce the bug is...
(let ((str (make-string 1600000 ?x)))
(mapconcat
#'(lambda (el)
el)
(list str) ""))
21.4 patch:
ChangeLog files diff command: cvs -q diff -U 0
Files affected: src/ChangeLog
Source files diff command: cvs -q diff -uN
Files affected: src/fns.c
Index: src/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.290.2.113
diff -u -p -U0 -r1.290.2.113 ChangeLog
--- src/ChangeLog 20 Nov 2006 18:29:42 -0000 1.290.2.113
+++ src/ChangeLog 7 Dec 2006 17:58:48 -0000
@@ -0,0 +1,8 @@
+2006-12-08 Nelson Ferreira <njsf(a)sxemacs.org>
+
+ * src/fns.c (XMALLOC_OR_ALLOCA,free_malloced_ptr,XMALLOC_UNBIND):
+ relocated the definitions to be used sooner in file.
+ (concat,plists_differ,mapcar1,Fmapconcat,Fmapcar): Use
+ XMALLOC_OR_ALLOCA macro instead of alloca to prevent stack
+ overflow.
+
Index: src/fns.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/fns.c,v
retrieving revision 1.33.2.4
diff -u -p -u -r1.33.2.4 fns.c
--- src/fns.c 31 Jan 2005 02:55:15 -0000 1.33.2.4
+++ src/fns.c 7 Dec 2006 17:57:54 -0000
@@ -49,6 +49,42 @@ Boston, MA 02111-1307, USA. */
#include "lstream.h"
#include "opaque.h"
+
+
+static Lisp_Object free_malloced_ptr(Lisp_Object unwind_obj)
+{
+ void *ptr = (void *)get_opaque_ptr(unwind_obj);
+ xfree(ptr);
+ free_opaque_ptr(unwind_obj);
+ return Qnil;
+}
+
+/* Don't use alloca for regions larger than this, lest we overflow
+ the stack. */
+#define MAX_ALLOCA 65536
+
+/* We need to setup proper unwinding, because there is a number of
+ ways these functions can blow up, and we don't want to have memory
+ leaks in those cases. */
+#define XMALLOC_OR_ALLOCA(ptr, len, type) do { \
+ size_t XOA_len = (len); \
+ if (XOA_len > MAX_ALLOCA ) { \
+ ptr = xnew_array (type, XOA_len); \
+ record_unwind_protect (free_malloced_ptr, \
+ make_opaque_ptr ((void *)ptr)); \
+ } \
+ else \
+ ptr = alloca_array (type, XOA_len); \
+} while (0)
+
+#define XMALLOC_UNBIND(ptr, len, speccount) do { \
+ if ((len) > MAX_ALLOCA) \
+ unbind_to (speccount, Qnil); \
+} while (0)
+
+
+
+
/* NOTE: This symbol is also used in lread.c */
#define FEATUREP_SYNTAX
@@ -604,6 +640,8 @@ concat (int nargs, Lisp_Object *args,
Bufbyte *string_result = 0;
Bufbyte *string_result_ptr = 0;
struct gcpro gcpro1;
+ int speccount = specpdl_depth();
+ Charcount total_length;
/* The modus operandi in Emacs is "caller gc-protects args".
However, concat is called many times in Emacs on freshly
@@ -621,7 +659,7 @@ concat (int nargs, Lisp_Object *args,
the result in the returned string's `string-translatable' property. */
#endif
if (target_type == c_string)
- args_mse = alloca_array (struct merge_string_extents_struct, nargs);
+ XMALLOC_OR_ALLOCA(args_mse, nargs, struct merge_string_extents_struct);
/* In append, the last arg isn't treated like the others */
if (last_special && nargs > 0)
@@ -670,7 +708,7 @@ concat (int nargs, Lisp_Object *args,
/* Charcount is a misnomer here as we might be dealing with the
length of a vector or list, but emphasizes that we're not dealing
with Bytecounts in strings */
- Charcount total_length;
+ /* Charcount total_length; */
for (argnum = 0, total_length = 0; argnum < nargs; argnum++)
{
@@ -686,8 +724,11 @@ concat (int nargs, Lisp_Object *args,
{
case c_cons:
if (total_length == 0)
+ {
/* In append, if all but last arg are nil, return last arg */
+ XMALLOC_UNBIND(args_mse, nargs, speccount);
RETURN_UNGCPRO (last_tail);
+ }
val = Fmake_list (make_int (total_length), Qnil);
break;
case c_vector:
@@ -707,7 +748,9 @@ concat (int nargs, Lisp_Object *args,
realloc()ing in order to make the char fit properly.
O(N^2) yuckage. */
val = Qnil;
- string_result = (Bufbyte *) alloca (total_length * MAX_EMCHAR_LEN);
+ XMALLOC_OR_ALLOCA( string_result,
+ total_length * MAX_EMCHAR_LEN,
+ Bufbyte );
string_result_ptr = string_result;
break;
default:
@@ -820,6 +863,8 @@ concat (int nargs, Lisp_Object *args,
args_mse[argnum].entry_offset, 0,
args_mse[argnum].entry_length);
}
+ XMALLOC_UNBIND(string_result, total_length * MAX_EMCHAR_LEN, speccount);
+ XMALLOC_UNBIND(args_mse, nargs, speccount);
}
if (!NILP (prev))
@@ -1840,6 +1885,7 @@ plists_differ (Lisp_Object a, Lisp_Objec
Lisp_Object *keys, *vals;
char *flags;
Lisp_Object rest;
+ int speccount = specpdl_depth();
if (NILP (a) && NILP (b))
return 0;
@@ -1851,9 +1897,9 @@ plists_differ (Lisp_Object a, Lisp_Objec
lb = XINT (Flength (b));
m = (la > lb ? la : lb);
fill = 0;
- keys = alloca_array (Lisp_Object, m);
- vals = alloca_array (Lisp_Object, m);
- flags = alloca_array (char, m);
+ XMALLOC_OR_ALLOCA(keys, m, Lisp_Object);
+ XMALLOC_OR_ALLOCA(vals, m, Lisp_Object);
+ XMALLOC_OR_ALLOCA(flags, m, char);
/* First extract the pairs from A. */
for (rest = a; !NILP (rest); rest = XCDR (XCDR (rest)))
@@ -1898,10 +1944,17 @@ plists_differ (Lisp_Object a, Lisp_Objec
if (flags [i] == 0)
goto MISMATCH;
+
+ XMALLOC_UNBIND(flags, m, speccount);
+ XMALLOC_UNBIND(vals, m, speccount);
+ XMALLOC_UNBIND(keys, m, speccount);
/* Ok. */
return 0;
MISMATCH:
+ XMALLOC_UNBIND(flags, m, speccount);
+ XMALLOC_UNBIND(vals, m, speccount);
+ XMALLOC_UNBIND(keys, m, speccount);
return 1;
}
@@ -2995,8 +3048,12 @@ mapcar1 (size_t leni, Lisp_Object *vals,
{
/* The string data of `sequence' might be relocated during GC. */
Bytecount slen = XSTRING_LENGTH (sequence);
- Bufbyte *p = alloca_array (Bufbyte, slen);
- Bufbyte *end = p + slen;
+ Bufbyte *p = NULL;
+ Bufbyte *end = NULL;
+ int speccount = specpdl_depth();
+
+ XMALLOC_OR_ALLOCA(p, slen, Bufbyte);
+ end = p + slen;
memcpy (p, XSTRING_DATA (sequence), slen);
@@ -3007,6 +3064,7 @@ mapcar1 (size_t leni, Lisp_Object *vals,
result = Ffuncall (2, args);
if (vals) vals[gcpro1.nvars++] = result;
}
+ XMALLOC_UNBIND(p, slen, speccount);
}
else if (BIT_VECTORP (sequence))
{
@@ -3038,12 +3096,14 @@ may be a list, a vector, a bit vector, o
{
EMACS_INT len = XINT (Flength (sequence));
Lisp_Object *args;
+ Lisp_Object result;
EMACS_INT i;
EMACS_INT nargs = len + len - 1;
+ int speccount = specpdl_depth();
if (len == 0) return build_string ("");
- args = alloca_array (Lisp_Object, nargs);
+ XMALLOC_OR_ALLOCA(args, nargs, Lisp_Object);
mapcar1 (len, args, function, sequence);
@@ -3053,7 +3113,9 @@ may be a list, a vector, a bit vector, o
for (i = 1; i < nargs; i += 2)
args[i] = separator;
- return Fconcat (nargs, args);
+ result = Fconcat(nargs, args);
+ XMALLOC_UNBIND(args, nargs, speccount);
+ return result;
}
DEFUN ("mapcar", Fmapcar, 2, 2, 0, /*
@@ -3064,11 +3126,17 @@ SEQUENCE may be a list, a vector, a bit
(function, sequence))
{
size_t len = XINT (Flength (sequence));
- Lisp_Object *args = alloca_array (Lisp_Object, len);
+ Lisp_Object *args = NULL;
+ Lisp_Object result;
+ int speccount = specpdl_depth();
+
+ XMALLOC_OR_ALLOCA(args, len, Lisp_Object);
mapcar1 (len, args, function, sequence);
- return Flist (len, args);
+ result = Flist(len, args);
+ XMALLOC_UNBIND(args, len, speccount);
+ return result;
}
DEFUN ("mapvector", Fmapvector, 2, 2, 0, /*
@@ -3571,38 +3639,6 @@ base64_decode_1 (Lstream *istream, Bufby
#undef ADVANCE_INPUT_IGNORE_NONBASE64
#undef STORE_BYTE
-static Lisp_Object
-free_malloced_ptr (Lisp_Object unwind_obj)
-{
- void *ptr = (void *)get_opaque_ptr (unwind_obj);
- xfree (ptr);
- free_opaque_ptr (unwind_obj);
- return Qnil;
-}
-
-/* Don't use alloca for regions larger than this, lest we overflow
- the stack. */
-#define MAX_ALLOCA 65536
-
-/* We need to setup proper unwinding, because there is a number of
- ways these functions can blow up, and we don't want to have memory
- leaks in those cases. */
-#define XMALLOC_OR_ALLOCA(ptr, len, type) do { \
- size_t XOA_len = (len); \
- if (XOA_len > MAX_ALLOCA) \
- { \
- ptr = xnew_array (type, XOA_len); \
- record_unwind_protect (free_malloced_ptr, \
- make_opaque_ptr ((void *)ptr)); \
- } \
- else \
- ptr = alloca_array (type, XOA_len); \
-} while (0)
-
-#define XMALLOC_UNBIND(ptr, len, speccount) do { \
- if ((len) > MAX_ALLOCA) \
- unbind_to (speccount, Qnil); \
-} while (0)
DEFUN ("base64-encode-region", Fbase64_encode_region, 2, 3, "r", /*
Base64-encode the region between START and END.
--
|---<Steve Youngs>---------------<GnuPG KeyID: A94B3003>---|
| SXEmacs - The only _______ you'll ever need. |
| Fill in the blank, yes, it's THAT good! |
|------------------------------------<steve(a)sxemacs.org>---|
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches
[PATCH 21.5] POP sync
18 years
Jerry James
PATCH 21.5
Our current pop.c has a number of problems flagged by some static
checkers, but the Emacs version checks clean. Here's a sync so we can
be as clean as a whistle, too.
lib-src/ChangeLog addition:
2006-08-11 Jerry James <james(a)xemacs.org>
* pop.h: Sync with Emacs.
* pop.c: Ditto.
xemacs-21.5 source patch:
Diff command: cvs -q diff -uN
Files affected: lib-src/pop.c lib-src/pop.h
Index: lib-src/pop.h
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lib-src/pop.h,v
retrieving revision 1.2
diff -d -u -r1.2 pop.h
--- lib-src/pop.h 2001/06/10 10:42:17 1.2
+++ lib-src/pop.h 2006/08/11 18:22:07
@@ -1,5 +1,6 @@
/* pop.h: Header file for the "pop.c" client POP3 protocol.
- Copyright (c) 1991,1993 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1993, 2002, 2003, 2004,
+ 2005, 2006 Free Software Foundation, Inc.
Written by Jonathan Kamens, jik(a)security.ov.com.
This file is part of XEmacs.
@@ -16,8 +17,10 @@
You should have received a copy of the GNU General Public License
along with XEmacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
+
+/* Synched up with: FSF 22.0.50. */
#include <stdio.h>
@@ -59,7 +62,8 @@
extern int pop_stat _ARGS((popserver server, int *count, int *size));
extern int pop_list _ARGS((popserver server, int message, int **IDs,
int **size));
-extern char *pop_retrieve _ARGS((popserver server, int message, int markfrom));
+extern int pop_retrieve _ARGS((popserver server, int message, int markfrom,
+ char **));
extern int pop_retrieve_first _ARGS((popserver server, int message,
char **response));
extern int pop_retrieve_next _ARGS((popserver server, char **line));
Index: lib-src/pop.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lib-src/pop.c,v
retrieving revision 1.10
diff -d -u -r1.10 pop.c
--- lib-src/pop.c 2004/09/20 19:19:11 1.10
+++ lib-src/pop.c 2006/08/11 18:22:07
@@ -1,5 +1,6 @@
/* pop.c: client routines for talking to a POP3-protocol post-office server
- Copyright (c) 1991, 1993, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1993, 1996, 1997, 1999, 2002, 2003, 2004,
+ 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2001 Ben Wing.
Written by Jonathan Kamens, jik(a)security.ov.com.
@@ -17,8 +18,10 @@
You should have received a copy of the GNU General Public License
along with XEmacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
+
+/* Synched up with: FSF 22.0.50. */
#ifdef HAVE_CONFIG_H
#define NO_SHORTNAMES /* Tell config not to load remap.h */
@@ -96,7 +99,7 @@
#ifdef KERBEROS
#ifndef KRB5
extern int krb_sendauth (/* long, int, KTEXT, char *, char *, char *,
- unsigned long, MSG_DAT *, CREDENTIALS *, Key_schedule,
+ u_long, MSG_DAT *, CREDENTIALS *, Key_schedule,
struct sockaddr_in *, struct sockaddr_in *,
char * */);
extern char *krb_realmofhost (/* char * */);
@@ -110,7 +113,7 @@
#endif
static int socket_connection (char *, int);
-static char *pop_getline (popserver);
+static int pop_getline (popserver, char **);
static int sendline (popserver, char *);
static int fullwrite (int, char *, int);
static int getok (popserver);
@@ -118,9 +121,11 @@
static int gettermination (popserver);
#endif
static void pop_trash (popserver);
-static char *find_crlf (char *);
+static char *find_crlf (char *, int);
-#define ERROR_MAX 80 /* a pretty arbitrary size */
+#define ERROR_MAX 160 /* a pretty arbitrary size, but needs
+ to be bigger than the original
+ value of 80 */
#define POP_PORT 110
#define KPOP_PORT 1109
#if defined(WIN32_NATIVE) || defined(CYGWIN)
@@ -130,7 +135,7 @@
#endif
#ifdef KERBEROS
#ifdef KRB5
-#define KPOP_SERVICE "k5pop";
+#define KPOP_SERVICE "k5pop"
#else
#define KPOP_SERVICE "kpop"
#endif
@@ -356,7 +361,7 @@
return (-1);
}
- if (sendline (server, "STAT") || (! (fromserver = pop_getline (server))))
+ if (sendline (server, "STAT") || (pop_getline (server, &fromserver) < 0))
return (-1);
if (strncmp (fromserver, "+OK ", 4))
@@ -448,7 +453,7 @@
free ((char *) *sizes);
return (-1);
}
- if (! (fromserver = pop_getline (server)))
+ if (pop_getline (server, &fromserver) < 0)
{
free ((char *) *IDs);
free ((char *) *sizes);
@@ -493,7 +498,7 @@
}
for (i = 0; i < how_many; i++)
{
- if (pop_multi_next (server, &fromserver))
+ if (pop_multi_next (server, &fromserver) <= 0)
{
free ((char *) *IDs);
free ((char *) *sizes);
@@ -512,7 +517,7 @@
}
(*sizes)[i] = atoi (fromserver);
}
- if (pop_multi_next (server, &fromserver))
+ if (pop_multi_next (server, &fromserver) < 0)
{
free ((char *) *IDs);
free ((char *) *sizes);
@@ -542,14 +547,17 @@
* markfrom
* If true, then mark the string "From " at the beginning
* of lines with '>'.
+ * msg_buf Output parameter to which a buffer containing the
+ * message is assigned.
*
- * Return value: A string pointing to the message, if successful, or
- * null with pop_error set if not.
+ * Return value: The number of bytes in msg_buf, which may contain
+ * embedded nulls, not including its final null, or -1 on error
+ * with pop_error set.
*
* Side effects: May kill connection on error.
*/
-char *
-pop_retrieve (popserver server, int message, int markfrom)
+int
+pop_retrieve (popserver server, int message, int markfrom, char **msg_buf)
{
int *IDs, *sizes, bufsize, fromcount = 0, cp = 0;
char *ptr, *fromserver;
@@ -562,11 +570,11 @@
}
if (pop_list (server, message, &IDs, &sizes))
- return (0);
+ return (-1);
if (pop_retrieve_first (server, message, &fromserver))
{
- return (0);
+ return (-1);
}
/*
@@ -584,17 +592,16 @@
{
strcpy (pop_error, "Out of memory in pop_retrieve");
pop_retrieve_flush (server);
- return (0);
+ return (-1);
}
- while (! (ret = pop_retrieve_next (server, &fromserver)))
+ while ((ret = pop_retrieve_next (server, &fromserver)) >= 0)
{
- int linesize;
-
if (! fromserver)
{
ptr[cp] = '\0';
- return (ptr);
+ *msg_buf = ptr;
+ return (cp);
}
if (markfrom && fromserver[0] == 'F' && fromserver[1] == 'r' &&
fromserver[2] == 'o' && fromserver[3] == 'm' &&
@@ -608,25 +615,19 @@
{
strcpy (pop_error, "Out of memory in pop_retrieve");
pop_retrieve_flush (server);
- return (0);
+ return (-1);
}
fromcount = 0;
}
ptr[cp++] = '>';
}
- linesize = strlen (fromserver);
- memcpy (&ptr[cp], fromserver, linesize);
- cp += linesize;
+ memcpy (&ptr[cp], fromserver, ret);
+ cp += ret;
ptr[cp++] = '\n';
}
- if (ret)
- {
- free (ptr);
- /* return (0); */
- }
- /* This function used to fall off the end, but that doesn't make any sense */
- return (0);
+ free (ptr);
+ return (-1);
}
int
@@ -636,6 +637,14 @@
return (pop_multi_first (server, pop_error, response));
}
+/*
+ Returns a negative number on error, 0 to indicate that the data has
+ all been read (i.e., the server has returned a "." termination
+ line), or a positive number indicating the number of bytes in the
+ returned buffer (which is null-terminated and may contain embedded
+ nulls, but the returned bytecount doesn't include the final null).
+ */
+
int
pop_retrieve_next (popserver server, char **line)
{
@@ -655,6 +664,14 @@
return (pop_multi_first (server, pop_error, response));
}
+/*
+ Returns a negative number on error, 0 to indicate that the data has
+ all been read (i.e., the server has returned a "." termination
+ line), or a positive number indicating the number of bytes in the
+ returned buffer (which is null-terminated and may contain embedded
+ nulls, but the returned bytecount doesn't include the final null).
+ */
+
int
pop_top_next (popserver server, char **line)
{
@@ -677,7 +694,7 @@
return (-1);
}
- if (sendline (server, command) || (! (*response = pop_getline (server))))
+ if (sendline (server, command) || (pop_getline (server, response) < 0))
{
return (-1);
}
@@ -701,10 +718,20 @@
}
}
+/*
+ Read the next line of data from SERVER and place a pointer to it
+ into LINE. Return -1 on error, 0 if there are no more lines to read
+ (i.e., the server has returned a line containing only "."), or a
+ positive number indicating the number of bytes in the LINE buffer
+ (not including the final null). The data in that buffer may contain
+ embedded nulls, but does not contain the final CRLF. When returning
+ 0, LINE is set to null. */
+
int
pop_multi_next (popserver server, char **line)
{
char *fromserver;
+ int ret;
if (! server->in_multi)
{
@@ -712,8 +739,7 @@
return (-1);
}
- fromserver = pop_getline (server);
- if (! fromserver)
+ if ((ret = pop_getline (server, &fromserver)) < 0)
{
return (-1);
}
@@ -729,13 +755,13 @@
else
{
*line = fromserver + 1;
- return (0);
+ return (ret - 1);
}
}
else
{
*line = fromserver;
- return (0);
+ return (ret);
}
}
@@ -743,21 +769,22 @@
pop_multi_flush (popserver server)
{
char *line;
+ int ret;
if (! server->in_multi)
{
return (0);
}
- while (! pop_multi_next (server, &line))
+ while ((ret = pop_multi_next (server, &line)))
{
- if (! line)
+ if (ret < 0)
{
- return (0);
+ return (-1);
}
}
- return (-1);
+ return (0);
}
/* Function: pop_delete
@@ -844,7 +871,7 @@
if (sendline (server, "LAST"))
return (-1);
- if (! (fromserver = pop_getline (server)))
+ if (pop_getline (server, &fromserver) < 0)
return (-1);
if (! strncmp (fromserver, "-ERR", 4))
@@ -968,6 +995,8 @@
#ifdef KERBEROS
#ifdef KRB5
krb5_error_code rem;
+ krb5_context kcontext = 0;
+ krb5_auth_context auth_context = 0;
krb5_ccache ccdef;
krb5_principal client, server;
krb5_error *err_ret;
@@ -978,6 +1007,7 @@
CREDENTIALS cred;
Key_schedule schedule;
int rem;
+ char *realhost;
#endif /* KRB5 */
#endif /* KERBEROS */
@@ -991,19 +1021,6 @@
}
#endif
- do
- {
- hostent = gethostbyname (host);
- try_count++;
- if ((! hostent)
- && ((h_errno != TRY_AGAIN) || (try_count == 5))
- )
- {
- strcpy (pop_error, "Could not determine POP server's address");
- return (-1);
- }
- } while (! hostent);
-
memset (&addr, 0, sizeof (addr));
addr.sin_family = AF_INET;
@@ -1042,18 +1059,29 @@
}
}
-#define SOCKET_ERROR "Could not create socket for POP connection: "
+#define POP_SOCKET_ERROR "Could not create socket for POP connection: "
sock = socket (PF_INET, SOCK_STREAM, 0);
if (sock < 0)
{
- strcpy (pop_error, SOCKET_ERROR);
+ strcpy (pop_error, POP_SOCKET_ERROR);
strncat (pop_error, strerror (errno),
- ERROR_MAX - sizeof (SOCKET_ERROR));
+ ERROR_MAX - sizeof (POP_SOCKET_ERROR));
return (-1);
}
+ do
+ {
+ hostent = gethostbyname (host);
+ try_count++;
+ if ((! hostent) && ((h_errno != TRY_AGAIN) || (try_count == 5)))
+ {
+ strcpy (pop_error, "Could not determine POP server's address");
+ return (-1);
+ }
+ } while (! hostent);
+
while (*hostent->h_addr_list)
{
memcpy (&addr.sin_addr, *hostent->h_addr_list, hostent->h_length);
@@ -1079,11 +1107,13 @@
if (! (flags & POP_NO_KERBEROS))
{
#ifdef KRB5
- krb5_init_ets ();
-
- if (rem = krb5_cc_default (&ccdef))
+ if ((rem = krb5_init_context (&kcontext)))
{
krb5error:
+ if (auth_context)
+ krb5_auth_con_free (kcontext, auth_context);
+ if (kcontext)
+ krb5_free_context (kcontext);
strcpy (pop_error, KRB_ERROR);
strncat (pop_error, error_message (rem),
ERROR_MAX - sizeof(KRB_ERROR));
@@ -1091,11 +1121,15 @@
return (-1);
}
- if (rem = krb5_cc_get_principal (ccdef, &client))
- {
- goto krb5error;
- }
+ if ((rem = krb5_auth_con_init (kcontext, &auth_context)))
+ goto krb5error;
+ if (rem = krb5_cc_default (kcontext, &ccdef))
+ goto krb5error;
+
+ if (rem = krb5_cc_get_principal (kcontext, ccdef, &client))
+ goto krb5error;
+
for (cp = hostent->h_name; *cp; cp++)
{
if (isupper (*cp))
@@ -1104,22 +1138,20 @@
}
}
- if (rem = krb5_sname_to_principal (hostent->h_name, POP_SERVICE,
- FALSE, &server))
- {
- goto krb5error;
- }
+ if (rem = krb5_sname_to_principal (kcontext, hostent->h_name,
+ POP_SERVICE, FALSE, &server))
+ goto krb5error;
- rem = krb5_sendauth ((krb5_pointer) &sock, "KPOPV1.0", client, server,
+ rem = krb5_sendauth (kcontext, &auth_context,
+ (krb5_pointer) &sock, "KPOPV1.0", client, server,
AP_OPTS_MUTUAL_REQUIRED,
0, /* no checksum */
0, /* no creds, use ccache instead */
ccdef,
- 0, /* don't need seq # */
- 0, /* don't need subsession key */
&err_ret,
+ 0, /* don't need subsession key */
0); /* don't need reply */
- krb5_free_principal (server);
+ krb5_free_principal (kcontext, server);
if (rem)
{
if (err_ret && err_ret->text.length)
@@ -1142,20 +1174,23 @@
ERROR_MAX - sizeof (KRB_ERROR));
}
if (err_ret)
- krb5_free_error (err_ret);
+ krb5_free_error (kcontext, err_ret);
+ krb5_auth_con_free (kcontext, auth_context);
+ krb5_free_context (kcontext);
CLOSESOCKET (sock);
return (-1);
}
#else /* ! KRB5 */
ticket = (KTEXT) malloc (sizeof (KTEXT_ST));
- rem = krb_sendauth (0L, sock, ticket, "pop", hostent->h_name,
- (char *) krb_realmofhost (hostent->h_name),
+ rem = krb_sendauth (0L, sock, ticket, "pop", realhost,
+ (char *) krb_realmofhost (realhost),
(unsigned long) 0, &msg_data, &cred, schedule,
(struct sockaddr_in *) 0,
(struct sockaddr_in *) 0,
"KPOPV0.1");
free ((char *) ticket);
+ free (realhost);
if (rem != KSUCCESS)
{
strcpy (pop_error, KRB_ERROR);
@@ -1182,15 +1217,20 @@
* Arguments:
* server The server from which to get the line of text.
*
- * Returns: A non-null pointer if successful, or a null pointer on any
- * error, with an error message copied into pop_error.
+ * Returns: The number of characters in the line, which is returned in
+ * LINE, not including the final null. A return value of 0
+ * indicates a blank line. A negative return value indicates an
+ * error (in which case the contents of LINE are undefined. In
+ * case of error, an error message is copied into pop_error.
*
* Notes: The line returned is overwritten with each call to pop_getline.
*
* Side effects: Closes the connection on error.
+ *
+ * THE RETURNED LINE MAY CONTAIN EMBEDDED NULLS!
*/
-static char *
-pop_getline (popserver server)
+static int
+pop_getline (popserver server, char **line)
{
#define GETLINE_ERROR "Error reading from server: "
@@ -1199,7 +1239,8 @@
if (server->data)
{
- char *cp = find_crlf (server->buffer + server->buffer_index);
+ char *cp = find_crlf (server->buffer + server->buffer_index,
+ server->data);
if (cp)
{
int found;
@@ -1213,8 +1254,11 @@
server->buffer_index += data_used;
if (pop_debug)
+ /* Embedded nulls will truncate this output prematurely,
+ but that's OK because it's just for debugging anyway. */
fprintf (stderr, "<<< %s\n", server->buffer + found);
- return (server->buffer + found);
+ *line = server->buffer + found;
+ return (data_used - 2);
}
else
{
@@ -1250,7 +1294,7 @@
{
strcpy (pop_error, "Out of memory in pop_getline");
pop_trash (server);
- return (0);
+ return (-1);
}
}
ret = RECV (server->file, server->buffer + server->data,
@@ -1261,13 +1305,13 @@
strncat (pop_error, strerror (errno),
ERROR_MAX - sizeof (GETLINE_ERROR));
pop_trash (server);
- return (0);
+ return (-1);
}
else if (ret == 0)
{
strcpy (pop_error, "Unexpected EOF from server in pop_getline");
pop_trash (server);
- return (0);
+ return (-1);
}
else
{
@@ -1275,7 +1319,8 @@
server->data += ret;
server->buffer[server->data] = '\0';
- cp = find_crlf (server->buffer + search_offset);
+ cp = find_crlf (server->buffer + search_offset,
+ server->data - search_offset);
if (cp)
{
int data_used = (cp + 2) - server->buffer;
@@ -1285,9 +1330,12 @@
if (pop_debug)
fprintf (stderr, "<<< %s\n", server->buffer);
- return (server->buffer);
+ *line = server->buffer;
+ return (data_used - 2);
}
- search_offset += ret;
+ /* As above, the "- 1" here is to account for the fact that
+ we may have read a CR without its accompanying LF. */
+ search_offset += ret - 1;
}
}
@@ -1317,12 +1365,24 @@
{
#define SENDLINE_ERROR "Error writing to POP server: "
int ret;
+ char *buf;
+
+ /* Combine the string and the CR-LF into one buffer. Otherwise, two
+ reasonable network stack optimizations, Nagle's algorithm and
+ delayed acks, combine to delay us a fraction of a second on every
+ message we send. (Movemail writes line without \r\n, client
+ kernel sends packet, server kernel delays the ack to see if it
+ can combine it with data, movemail writes \r\n, client kernel
+ waits because it has unacked data already in its outgoing queue,
+ client kernel eventually times out and sends.)
+ This can be something like 0.2s per command, which can add up
+ over a few dozen messages, and is a big chunk of the time we
+ spend fetching mail from a server close by. */
+ buf = alloca (strlen (line) + 3);
+ strcpy (buf, line);
+ strcat (buf, "\r\n");
ret = fullwrite (server->file, line, strlen (line));
- if (ret >= 0)
- { /* 0 indicates that a blank line was written */
- ret = fullwrite (server->file, "\r\n", 2);
- }
if (ret < 0)
{
@@ -1351,10 +1411,10 @@
fullwrite (int fd, char *buf, int nbytes)
{
char *cp;
- int ret;
+ int ret = 0;
cp = buf;
- while ((ret = SEND (fd, cp, nbytes, 0)) > 0)
+ while (nbytes && ((ret = SEND (fd, cp, nbytes, 0)) > 0))
{
cp += ret;
nbytes -= ret;
@@ -1382,7 +1442,7 @@
{
char *fromline;
- if (! (fromline = pop_getline (server)))
+ if (pop_getline (server, &fromline) < 0)
{
return (-1);
}
@@ -1420,8 +1480,7 @@
{
char *fromserver;
- fromserver = pop_getline (server);
- if (! fromserver)
+ if (pop_getline (server, &fromserver) < 0)
return (-1);
if (strcmp (fromserver, "."))
@@ -1492,17 +1551,16 @@
#endif
}
-/* Return a pointer to the first CRLF in IN_STRING,
- or 0 if it does not contain one. */
+/* Return a pointer to the first CRLF in IN_STRING, which can contain
+ embedded nulls and has LEN characters in it not including the final
+ null, or 0 if it does not contain one. */
static char *
-find_crlf (char *in_string)
+find_crlf (char *in_string, int len)
{
- while (1)
+ while (len--)
{
- if (! *in_string)
- return (0);
- else if (*in_string == '\r')
+ if (*in_string == '\r')
{
if (*++in_string == '\n')
return (in_string - 1);
@@ -1510,7 +1568,7 @@
else
in_string++;
}
- /* NOTREACHED */
+ return (0);
}
#endif /* MAIL_USE_POP */
--
Jerry James, Assistant Professor james(a)xemacs.org
Computer Science Department http://www.cs.usu.edu/~jerry/
Utah State University
[PATCH 21.5] gnuclient buffer overflow fixes
18 years
Jerry James
PATCH 21.5
The gnuclient.c part of this patch will not apply to 21.4. I can make a
new patch for 21.4 if desired, though. Here are fixes for a few, um,
undesirable features found with a static checker.
lib-src/ChangeLog addition:
2006-08-08 Jerry James <james(a)xemacs.org>
* gnuslib.c (disconnect_from_server): shutdown() has been fine on
Linux for a long time now; use it. Also, don't use length to
access the buffer unless it is positive, not just nonzero.
* gnuclient.c (filename_expand): Initialize the last array element
to get a valid C string in case of overflow. Use strncat to avoid
buffer overruns.
* gnuclient.c (main): Use strncpy to avoid buffer overruns.
xemacs-21.5 source patch:
Diff command: cvs -q diff -uN
Files affected: lib-src/gnuclient.c
===================================================================
RCS lib-src/gnuslib.c
===================================================================
RCS
Index: lib-src/gnuslib.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lib-src/gnuslib.c,v
retrieving revision 1.12
diff -d -u -r1.12 gnuslib.c
--- lib-src/gnuslib.c 2001/08/13 04:45:48 1.12
+++ lib-src/gnuslib.c 2006/08/08 20:27:59
@@ -409,13 +409,11 @@
send_string(s,EOT_STR); /* make sure server gets string */
-#if !defined (linux) && !defined (_SCO_DS)
+#ifndef _SCO_DS
/*
- * shutdown is completely hozed under linux. If s is a unix domain socket,
- * you'll get EOPNOTSUPP back from it. If s is an internet socket, you get
- * a broken pipe when you try to read a bit later. The latter
- * problem is fixed for linux versions >= 1.1.46, but the problem
- * with unix sockets persists. Sigh.
+ * There used to be a comment here complaining about ancient Linux
+ * versions. It is no longer relevant. I don't know why _SCO_DS is
+ * verboten here, as the original comment did not say.
*/
if (shutdown(s,1) == -1) {
@@ -434,7 +432,7 @@
#else
while ((length = read(s,buffer,GSERV_BUFSZ)) > 0 ||
(length == -1 && errno == EINTR)) {
- if (length) {
+ if (length > 0) {
buffer[length] = '\0';
if (echo) {
fputs(buffer,stdout);
Index: lib-src/gnuclient.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lib-src/gnuclient.c,v
retrieving revision 1.27
diff -d -u -r1.27 gnuclient.c
--- lib-src/gnuclient.c 2004/12/06 23:23:41 1.27
+++ lib-src/gnuclient.c 2006/08/08 20:27:59
@@ -187,7 +187,7 @@
#endif
int len;
- fullpath[0] = '\0';
+ fullpath[0] = fullpath[QXE_PATH_MAX] = '\0';
#ifdef CYGWIN
/*
@@ -200,7 +200,7 @@
if (filename[0] && filename[0] == '/')
{
/* Absolute (unix-style) pathname. Do nothing */
- strcat (fullpath, filename);
+ strncat (fullpath, filename, QXE_PATH_MAX);
}
else
{
@@ -208,15 +208,18 @@
and prepend it. FIXME: need to fix the case of DOS paths like
"\foo", where we need to get the current drive. */
- strcat (fullpath, get_current_working_directory ());
+ strncat (fullpath, get_current_working_directory (), QXE_PATH_MAX);
len = strlen (fullpath);
- if (len > 0 && fullpath[len-1] == '/') /* trailing slash already? */
- ; /* yep */
- else
- strcat (fullpath, "/"); /* nope, append trailing slash */
+ /* If no trailing slash, add one */
+ if (len <= 0 || (fullpath[len - 1] != '/' && len < QXE_PATH_MAX))
+ {
+ strcat (fullpath, "/");
+ len++;
+ }
+
/* Don't forget to add the filename! */
- strcat (fullpath,filename);
+ strncat (fullpath, filename, QXE_PATH_MAX - len);
}
} /* filename_expand */
@@ -435,7 +438,7 @@
break;
case 'r':
GET_ARGUMENT (remotearg, "-r");
- strcpy (remotepath, remotearg);
+ strncpy (remotepath, remotearg, QXE_PATH_MAX);
rflg = 1;
break;
#endif /* INTERNET_DOMAIN_SOCKETS */
@@ -590,7 +593,7 @@
* to this machine */
if ((ptr = getenv ("GNU_NODE")) != NULL)
/* user specified a path */
- strcpy (remotepath, ptr);
+ strncpy (remotepath, ptr, QXE_PATH_MAX);
}
#if 0 /* This is really bogus... re-enable it if you must have it! */
#if defined (hp9000s300) || defined (hp9000s800)
--
Jerry James, Assistant Professor james(a)xemacs.org
Computer Science Department http://www.cs.usu.edu/~jerry/
Utah State University
Fast lock mode issue
18 years
Nelson Ferreira
For a long time I have been having a problem with closing some
buffers. In order to be able to close them I had to manually turn off
font-lock mode.
One such buffer has been the Info buffer.
Here is the back trace:
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
expand-file-name(nil)
fast-lock-cache-name("~/.sxemacs/flc")
fast-lock-save-cache()
fast-lock-save-cache-before-kill-buffer()
kill-buffer("*info*")
call-interactively(kill-buffer)
I was able to fix it with this small patch:
$ cvs diff -ub fast-lock.el
Index: fast-lock.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/edit-utils/fast-lock.el,v
retrieving revision 1.4
diff -u -u -b -r1.4 fast-lock.el
--- fast-lock.el 2006/03/07 07:10:32 1.4
+++ fast-lock.el 2006/11/13 01:06:08
@@ -526,7 +526,8 @@
See `fast-lock-cache-directory'."
(if (string-equal directory ".")
(concat buffer-file-name ".flc")
- (let* ((bufile (expand-file-name buffer-file-truename))
+ (let* ((bufile (expand-file-name (or buffer-file-truename
+ buffer-file-name)))
(chars-alist
(cond
((eq system-type 'emx)
--
Nelson Ferreira
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches
patch for Info-find-emacs-command-nodes
18 years
Jeff Miller
The regex in Info-find-command-nodes shouldn't be tied to the end of
line.
Most lines in Command Index look like:
* calendar: Calendar/Diary. (line 6)
The regex only works for lines that are split across two lines, like
* calendar-backward-day: Calendar Unit Motion.
(line 34)
Here is a test-case:
(let ((where
(Info-find-emacs-command-nodes 'calendar)))
(Info-find-node (car (car where)) (car (cdr (car where)))))
21.4 requires a similar patch.
2006-10-14 Jeff Miller <jmiller(a)xemacs.org>
* info.el (Info-find-emacs-command-nodes): fix regex for find
command node.
--- lisp/info.el.orig 2006-10-13 20:03:38.000000000 -0400
+++ lisp/info.el 2006-10-14 17:03:17.000000000 -0400
@@ -3117,7 +3117,7 @@
\(FILENAME NODENAME BUFFERPOS\)."
(let ((where '())
(cmd-desc (concat "^\\* " (regexp-quote (symbol-name command))
- ":\\s *\\(.*\\)\\.$")))
+ ":\\s *\\(.*\\)\\.")))
(save-excursion
(Info-find-node "XEmacs" "Command Index")
;; Take the index node off the Info history.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches
[AC21.5] Fix typo in call to GTK_DEVICE
18 years
Vin Shelton
APPROVE COMMIT 21.5
Index: src/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.1029
diff -a -u -r1.1029 ChangeLog
--- src/ChangeLog 2006/12/08 02:21:58 1.1029
+++ src/ChangeLog 2006/12/09 18:42:55
@@ -1,3 +1,8 @@
+2006-12-09 Vin Shelton <acs(a)xemacs.org>
+
+ * sound.c (init_native_sound): Fix typo in call to GTK_DEVICE
+ macro.
+
2006-12-07 Vin Shelton <acs(a)xemacs.org>
* fileio.c: Added cast to qxeGetNamedSecurityInfofix call to fix
Index: src/sound.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/sound.c,v
retrieving revision 1.28
diff -a -u -r1.28 sound.c
--- src/sound.c 2006/11/29 19:10:03 1.28
+++ src/sound.c 2006/12/09 18:42:56
@@ -590,7 +590,7 @@
static void
init_native_sound (struct device *d)
{
- if (!(DEVICE_X_P(d) || DEVICE_GTK_P(dev)))
+ if (!(DEVICE_X_P(d) || DEVICE_GTK_P(d)))
DEVICE_ON_CONSOLE_P (d) = 1;
#ifdef HAVE_X_WINDOWS
else
--
The Journey by Mary Oliver
http://www.poemhunter.com/p/m/poem.asp?poet=6771&poem=30506
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches
[AC21.5 R21.4] Avoid a crash in Cygwin when clicking File -> Print under Win32
18 years
Aidan Kehoe
Ar an t-ochtú lá is fiche de mí na Samhain, scríobh Dr. Volker Zell:
> Aidan, can we install this patch for 21.4 and 21.5 ? It seems to do the
> right thing.
It’s Vin’s call as to whether it goes into 21.4, but I see no reason for it
not to.
APPROVE COMMIT 21.5, RECOMMEND 21.4.
NOTE: This patch has been committed.
src/ChangeLog addition:
2006-11-29 Aidan Kehoe <kehoea(a)parhasard.net>
* sound.c (init_native_sound):
Only X11 and GTK devices can possibly not be on the console of the
associated machine. Fixes a crash when init_native_sound is called
on a msprinter device.
XEmacs Trunk source patch:
Diff command: cvs -q diff -Nu
Files affected: src/sound.c
===================================================================
RCS
Index: src/sound.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/sound.c,v
retrieving revision 1.27
diff -u -u -r1.27 sound.c
--- src/sound.c 2006/07/11 23:40:17 1.27
+++ src/sound.c 2006/11/29 19:06:06
@@ -590,7 +590,7 @@
static void
init_native_sound (struct device *d)
{
- if (DEVICE_TTY_P (d) || DEVICE_STREAM_P (d) || DEVICE_MSWINDOWS_P(d))
+ if (!(DEVICE_X_P(d) || DEVICE_GTK_P(dev)))
DEVICE_ON_CONSOLE_P (d) = 1;
#ifdef HAVE_X_WINDOWS
else
--
Santa Maradona, priez pour moi!
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches
[21.4] Documentation fixes
18 years
Hans de Graaff
The following patch is one of the patches that are applied to XEmacs in
Gentoo. It would be great if it could also be applied to the 21.4 tree so
that we can remove the patches.
Both problems have been fixed in 21.5 already.
Kind regards,
Hans
Index: emodules.texi
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/man/emodules.texi,v
retrieving revision 1.2.2.2
diff -u -B -r1.2.2.2 emodules.texi
--- man/emodules.texi 2002/08/20 11:35:22 1.2.2.2
+++ man/emodules.texi 2006/12/09 14:21:22
@@ -3,6 +3,9 @@
@c %**start of header
@setfilename ../info/emodules.info
@settitle Extending Emacs using C Modules
+@direntry
+* Emodules: (emodules). XEmacs dynamically loadable module support.
+@end direntry
@c %**end of header
@c
Index: external-widget.texi
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/man/external-widget.texi,v
retrieving revision 1.3.2.1
diff -u -B -r1.3.2.1 external-widget.texi
--- man/external-widget.texi 2002/04/30 16:06:06 1.3.2.1
+++ man/external-widget.texi 2006/12/09 14:21:22
@@ -4,7 +4,7 @@
@ifinfo
@dircategory XEmacs Editor
@direntry
-* External Widget: (external-widget) External Client Widget.
+* External Widget: (external-widget). External Client Widget.
@end direntry
@end ifinfo
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches
Fully expand directories before doing comparisons in configure.ac
18 years
Michael Sperber
This should fix at least some of the path-searching-related problems
observed after the switch to autoconf 2.60. Will commit on Thursday
or so unless somebody objects.
2006-11-23 Mike Sperber <mike(a)xemacs.org>
* configure.ac (XE_EXPAND_VARIABLE): Fully expand the various
directories before comparing them for figuring out which of them
are user-defined. Use XE_EPXAND_VARIABLE macro created for this
purpose where applicable.
--
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla
Index: configure.ac
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/configure.ac,v
retrieving revision 1.48
diff -u -r1.48 configure.ac
--- configure.ac 16 Nov 2006 11:22:33 -0000 1.48
+++ configure.ac 5 Dec 2006 08:14:27 -0000
@@ -1051,7 +1051,20 @@
else
AC_DEFINE(EXEC_PREFIX_USER_DEFINED)
fi
-if test "x$datadir" != 'x${prefix}/share'
+
+define([XE_EXPAND_VARIABLE],
+[$2=[$]$1
+while true; do
+ case "[$]$2" in
+ *\[$]* ) eval "$2=[$]$2" ;;
+ *) break ;;
+ esac
+done])dnl XE_EXPAND_VARIABLE
+
+XE_EXPAND_VARIABLE(prefix,prefix_expanded)
+XE_EXPAND_VARIABLE(datadir,datadir_expanded)
+
+if test "x$datadir_expanded" != "x$prefix_expanded/share"
then
AC_DEFINE(INFODIR_USER_DEFINED)
AC_DEFINE(LISPDIR_USER_DEFINED)
@@ -1062,15 +1075,25 @@
else
datadir='${prefix}/lib'
fi
-if test "x$libdir" != 'x${exec_prefix}/lib'
+
+XE_EXPAND_VARIABLE(exec_prefix,exec_prefix_expanded)
+XE_EXPAND_VARIABLE(libdir,libdir_expanded)
+
+if test "x$libdir_expanded" != "x$exec_prefix_expanded/lib"
then
AC_DEFINE(ARCHLIBDIR_USER_DEFINED)
fi
-if test "x$mandir" = 'x${prefix}/man'
+
+XE_EXPAND_VARIABLE(mandir,mandir_expanded)
+
+if test "x$mandir_expanded" = "x$prefix_expanded/man"
then
mandir='${prefix}/man/man1'
fi
-if test "x$infodir" != 'x${prefix}/info'
+
+XE_EXPAND_VARIABLE(infodir,infodir_expanded)
+
+if test "x$infodir_expanded" != "x${prefix_expanded}/info"
then
AC_DEFINE(INFODIR_USER_DEFINED)
else
@@ -5660,148 +5683,70 @@
AC_SUBST(infodir)
AC_SUBST(INFODIR_USER_DEFINED)
-INFODIR=$infodir
-while true; do
- case "$INFODIR" in
- *\$* ) eval "INFODIR=$INFODIR" ;;
- *) break ;;
- esac
-done
+XE_EXPAND_VARIABLE(infodir,INFODIR)
AC_SUBST(INFODIR)
AC_SUBST(infopath,$with_infopath)
AC_SUBST(INFOPATH_USER_DEFINED)
-INFOPATH=$with_infopath
-while true; do
- case "$INFOPATH" in
- *\$* ) eval "INFOPATH=$INFOPATH" ;;
- *) break ;;
- esac
-done
-AC_SUBST(INFOPATH)
+XE_EXPAND_VARIABLE(with_info_path,INFOPATH)
test -n "$with_user_packages" && with_early_packages=$with_user_packages
AC_SUBST(early_packages,$with_early_packages)
AC_SUBST(EARLY_PACKAGE_DIRECTORIES_USER_DEFINED)
-EARLY_PACKAGE_DIRECTORIES=$with_early_packages
-while true; do
- case "$EARLY_PACKAGE_DIRECTORIES" in
- *\$* ) eval "EARLY_PACKAGE_DIRECTORIES=$EARLY_PACKAGE_DIRECTORIES" ;;
- *) break ;;
- esac
-done
+XE_EXPAND_VARIABLE(with_early_packages,EARLY_PACKAGE_DIRECTORIES)
AC_SUBST(EARLY_PACKAGE_DIRECTORIES)
test -n "$with_system_packages" && with_late_packages=$with_system_packages
AC_SUBST(late_packages,$with_late_packages)
AC_SUBST(LATE_PACKAGE_DIRECTORIES_USER_DEFINED)
-LATE_PACKAGE_DIRECTORIES=$with_late_packages
-while true; do
- case "$LATE_PACKAGE_DIRECTORIES" in
- *\$* ) eval "LATE_PACKAGE_DIRECTORIES=$LATE_PACKAGE_DIRECTORIES" ;;
- *) break ;;
- esac
-done
+XE_EXPAND_VARIABLE(with_late_packages,LATE_PACKAGE_DIRECTORIES)
AC_SUBST(LATE_PACKAGE_DIRECTORIES)
test -n "$with_legacy_packages" && with_last_packages=$with_legacy_packages
AC_SUBST(last_packages,$with_last_packages)
AC_SUBST(LAST_PACKAGE_DIRECTORIES_USER_DEFINED)
-LAST_PACKAGE_DIRECTORIES=$with_last_packages
-while true; do
- case "$LAST_PACKAGE_DIRECTORIES" in
- *\$* ) eval "LAST_PACKAGE_DIRECTORIES=$LAST_PACKAGE_DIRECTORIES" ;;
- *) break ;;
- esac
-done
+XE_EXPAND_VARIABLE(with_last_packages,LAST_PACKAGE_DIRECTORIES)
AC_SUBST(LAST_PACKAGE_DIRECTORIES)
AC_SUBST(package_path,$with_package_path)
AC_SUBST(PACKAGE_PATH_USER_DEFINED)
-PACKAGE_PATH=$with_package_path
-while true; do
- case "$PACKAGE_PATH" in
- *\$* ) eval "PACKAGE_PATH=$PACKAGE_PATH" ;;
- *) break ;;
- esac
-done
+XE_EXPAND_VARIABLE(with_package_path,PACKAGE_PATH)
AC_SUBST(PACKAGE_PATH)
AC_SUBST(lispdir, $with_lispdir)
AC_SUBST(LISPDIR_USER_DEFINED)
-LISPDIR=$with_lispdir
-while true; do
- case "$LISPDIR" in
- *\$* ) eval "LISPDIR=$LISPDIR" ;;
- *) break ;;
- esac
-done
+XE_EXPAND_VARIABLE(with_lispdir,LISPDIR)
AC_SUBST(LISPDIR)
AC_SUBST(moduledir,$with_moduledir)
AC_SUBST(MODULEDIR_USER_DEFINED)
-MODULEDIR=$with_moduledir
-while true; do
- case "$MODULEDIR" in
- *\$* ) eval "MODULEDIR=$MODULEDIR" ;;
- *) break ;;
- esac
-done
+XE_EXPAND_VARIABLE(with_moduledir,MODULEDIR)
AC_SUBST(MODULEDIR)
AC_SUBST(sitelispdir,$with_sitelispdir)
AC_SUBST(SITELISPDIR_USER_DEFINED)
-SITELISPDIR=$sitelispdir
-while true; do
- case "$SITELISPDIR" in
- *\$* ) eval "SITELISPDIR=$SITELISPDIR" ;;
- *) break ;;
- esac
-done
+XE_EXPAND_VARIABLE(sitelispdir,SITELISPDIR)
AC_SUBST(SITELISPDIR)
AC_SUBST(sitemoduledir)
AC_SUBST(SITEMODULEDIR_USER_DEFINED)
-SITEMODULEDIR=$sitemoduledir
-while true; do
- case "$SITEMODULEDIR" in
- *\$* ) eval "SITEMODULEDIR=$SITEMODULEDIR" ;;
- *) break ;;
- esac
-done
+XE_EXPAND_VARIABLE(sitemoduledir,SITEMODULEDIR)
AC_SUBST(SITEMODULEDIR)
AC_SUBST(etcdir,$with_etcdir)
AC_SUBST(ETCDIR_USER_DEFINED)
-ETCDIR=$with_etcdir
-while true; do
- case "$ETCDIR" in
- *\$* ) eval "ETCDIR=$ETCDIR" ;;
- *) break ;;
- esac
-done
+XE_EXPAND_VARIABLE(with_etcdir,ETCDIR)
AC_SUBST(ETCDIR)
AC_SUBST(archlibdir,$with_archlibdir)
AC_SUBST(ARCHLIBDIR_USER_DEFINED)
ARCHLIBDIR=$with_archlibdir
-while true; do
- case "$ARCHLIBDIR" in
- *\$* ) eval "ARCHLIBDIR=$ARCHLIBDIR" ;;
- *) break ;;
- esac
-done
+XE_EXPAND_VARIABLE(with_archlibdir,ARCHLIBDIR)
AC_SUBST(ARCHLIBDIR)
AC_SUBST(docdir,$with_docdir)
AC_SUBST(DOCDIR_USER_DEFINED)
-DOCDIR=$with_docdir
-while true; do
- case "$DOCDIR" in
- *\$* ) eval "DOCDIR=$DOCDIR" ;;
- *) break ;;
- esac
-done
+XE_EXPAND_VARIABLE(with_docdir,DOCDIR)
AC_SUBST(DOCDIR)
AC_SUBST(docdir)
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches
[AC21.4] Patch for new xpm location on cygwin
18 years
Vin Shelton
APPROVE COMMIT 21.4
This patch was inspired by Rick Rankin's patch for 21.5.
The corresponding configure patch has been applied, too.
- Vin
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/ChangeLog,v
retrieving revision 1.241.2.89
diff -a -u -r1.241.2.89 ChangeLog
--- ChangeLog 2006/07/01 05:19:36 1.241.2.89
+++ ChangeLog 2006/12/08 03:27:12
@@ -1,3 +1,8 @@
+2006-12-07 Vin Shelton <acs(a)xemacs.org>
+
+ * configure.in: Find relocated xpm library under cygwin.
+ Patch lifted from Rick Rankin's 21.5 version of the patch.
+
2006-05-17 Stephen J. Turnbull <stephen(a)xemacs.org>
* PROBLEMS: X11R7 loses x11/bitmaps/gray.
Index: configure.in
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/Attic/configure.in,v
retrieving revision 1.151.2.37
diff -a -u -r1.151.2.37 configure.in
--- configure.in 2006/01/31 22:58:40 1.151.2.37
+++ configure.in 2006/12/08 03:27:14
@@ -3359,6 +3359,7 @@
dnl -- should only happen if CYGWIN && WITH_XPM && WITH_MSW && !WITH_X
libpath_xpm=
incpath_xpm=
+ libname_xpm="-lXpm"
case "$opsys" in
cygwin*)
cygwin_top=`eval gcc -print-search-dirs | sed -ne s'/install: //p'`
@@ -3369,6 +3370,7 @@
dnl hardcode "standard" non-X11 xpm lib/inc dirs
msw) libpath_xpm="-L${cygwin_top}/lib/noX"
incpath_xpm="-I${cygwin_top}/include/noX"
+ libname_xpm="-lXpm-noX"
;;
dnl not supported on cygwin (yet?)
gtk) ;;
@@ -3387,7 +3389,7 @@
XE_PREPEND("$incpath_xpm", CFLAGS)
XE_PREPEND("$libpath_xpm", LDFLAGS)
AC_MSG_CHECKING(for Xpm - no older than 3.4f)
- xe_check_libs=-lXpm
+ xe_check_libs="$libname_xpm"
AC_TRY_RUN([#define XPM_NUMBERS
#include <X11/xpm.h>
int main(int c, char **v) {
@@ -3422,10 +3424,10 @@
dnl #### but doesn't actually verify this assumption.
AC_DEFINE(HAVE_XPM)
XE_PREPEND("$libpath_xpm", LDFLAGS)
- XE_PREPEND(-lXpm, libs_x)
+ XE_PREPEND("$libname_xpm", libs_x)
XE_PREPEND("$incpath_xpm", CFLAGS)
AC_MSG_CHECKING(for \"FOR_MSW\" xpm)
- xe_check_libs=-lXpm
+ xe_check_libs="$libname_xpm"
AC_TRY_LINK(, [XpmCreatePixmapFromData()],
[xpm_for_msw=no],
[xpm_for_msw=yes])
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches