delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2018/01/07/07:47:49

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Message-ID: <5A5217F0.6030506@gmx.de>
Date: Sun, 07 Jan 2018 13:52:00 +0100
From: "Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp AT delorie DOT com]" <djgpp AT delorie DOT com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: smake-1.2.5
References: <p2r0fa$jbp$1 AT adenine DOT netfront DOT net>
In-Reply-To: <p2r0fa$jbp$1@adenine.netfront.net>
X-Provags-ID: V03:K0:LUN3cQC9AZgjfMEKYn2T/JWCLxepZDcNZ3mGHu6JWBKVCxmrX5Q
L3XXc8Aooiw5vsbNVApf5DL+0nUFcdQmJfsSWRvIrrz/W8xqQsC7n5YgkV1qN5RoDqU53qV
20mzbVf5/4ygpD0eT9DdgtbuQh0XHIubYzIhogkFKUsk4yjvC/nfWvECLPbA/uo3Lx8xuFT
CGqHiiiLGM+w+BOf+m/+w==
X-UI-Out-Filterresults: notjunk:1;V01:K0:CvW0j+iNg50=:qrDSRcIKXiL/3wzPI2ncd5
Yt70rcVh0lkF6ZG5dhunIii6yYcjPHIl2ycUxCYBur3ps2RMQwhF+qIkbo5gYqNGQMsD4Ub6/
W4PEZJwW7LrmABU4JyJA7U/jCUzScmbiQUPF9hfQyDemEI12ArVFvUPkhpHqyFRXUV4M0kpUG
uMW7CzkConBzSMpvSpx/m37vjIXamhS+jSe0f1wC/GNpjEsw9GogJuuu5ZZkjwAn/eQvbX8SZ
KzBIiuE3qJD1kpCIS2hze8/VtWYyz2OCCX/C+XxQ1sLgxMjYCIBy6Obv82a5cmpI2lY/T9kvM
mghDAJxpqlKBZvd3sUGy7F9Sw6234/JqMgTvE0SGVuzSi2DtIq+8wTxCLiq7bjXWV15aDbubK
/Lsi7bZfi65uRbysOAr1LtDau/HwxLtSaj0bhaeP+LymCcOM7diW2CfZuNZDccr+IlU/i2LEf
PHGiGCPQEU/Y8JoR4pMb1CYYxii01NxCApd1lIQqn7ynUiafj/T9JK7ZuNJYeqRmyViuh3sHy
PZUc54qsyhRz1gvgk0cn/blqwCeklakj+Jd2amkqtKxln6ioSEMX9Kglrzjao3ZRUQR/4Rf+N
zVV/X1CpY5o71MAyu2Gn8105PUbU1nl/uNHd5i7lx808u2oArWlo0M55YPwRQM165GTHTX0RF
LOQkjvns9kiQiA1dNXgqIWROtUXQwAno2dkKuLm20mKiGa9IQxoi6iYqaUJnFgEaW0PMPB2j6
FXIG94x0mln6AW/0qdDC0tk5nk+n6j0QzuzKPYrIzIs6Hd4HOypSZ1PtxCZ+rbgSXc0qQdcsM
5NHzT3pHJXeBsPfH+4Se9Arhpgtow==
Reply-To: djgpp AT delorie DOT com

This is a multi-part message in MIME format.
--------------050100070406050505010309
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Am 06.01.2018 18:19, schrieb david peterac (peters DOT al AT gmx DOT com) [via djgpp AT delorie DOT com]:
> Dear,
>
> Can You explain me log of compiled smake-1.2.5 with djdev 2.05 ?
>
> D:\djgpp\src\cdrtools\smake-1.2.5\psmake>sh
> sh-2.05b$ ./smake
> free: memory fouled
> Exiting due to signal SIGABRT
> Raised at eip=0001d945
> eax=000c7924 ebx=00000120 ecx=00000011 edx=00000000 esi=000c8bdc
> edi=000c7a40
> ebp=00000000 esp=000c7910 program=D:\djgpp\src\cdrtools\SMAKE-~1.5\psmake
> \smake
> cs: sel=01ff  base=02ad0000  limit=000cffff
> ds: sel=0207  base=02ad0000  limit=000cffff
> es: sel=0207  base=02ad0000  limit=000cffff
> fs: sel=01d7  base=0000c810  limit=0000ffff
> gs: sel=0217  base=00000000  limit=0010ffff
> ss: sel=0207  base=02ad0000  limit=000cffff
> App stack: [000c8b68..00048b68]  Exceptn stack: [00048ab4..00046b74]
>
> Call frame traceback EIPs:
>    0x0001d945 ___djgpp_traceback_exit+101
> sh-2.05b$ symify.exe ./smake
> sh-2.05b$
>
> Thanks David


There is a bug in searchfileinpath.  Here the variable path is used as
pointer to allocated memory by strdup and at the same time as incremental
counter along the path.  This has the consecuence that later when path is
passed to free, path no longer points to the beginning of the allocated memory.
This is a bug of the DJGPP port of this program.  The patch below will
fix the issue.

Regards,
Juan M. Guerrero






diff -aprNU5 smake-1.2.5.orig/lib/searchinpath.c smake-1.2.5/lib/searchinpath.c
--- smake-1.2.5.orig/lib/searchinpath.c	2010-11-18 22:49:52 +0000
+++ smake-1.2.5/lib/searchinpath.c	2018-01-07 02:20:18 +0000
@@ -125,10 +125,11 @@ searchfileinpath(name, mode, file_mode,
  #ifdef __DJGPP__
  	path = strdup(path);
  	if (path == NULL)
  		return (NULL);
  	strbs2s(path);	/* PATH under DJGPP can contain both slashes */
+	pn = path;	/* Remember PATH pointer */
  #endif

  	/*
  	 * A PATH name search should lead us to the path under which we
  	 * called the binary, but not necessarily to the install path as
@@ -146,11 +147,11 @@ searchfileinpath(name, mode, file_mode,
  		if ((np = searchonefile(name, mode,
  					(file_mode & SIP_PLAIN_FILE) != 0,
  					xn,
  					nbuf, np, ep)) != NULL) {
  #ifdef __DJGPP__
-			free(path);
+			free(pn);
  #endif
  			seterrno(oerrno);
  			return (np);
  		}
  		if (err == 0) {
@@ -161,11 +162,11 @@ searchfileinpath(name, mode, file_mode,
  		if (*path == '\0')
  			break;
  		path++;
  	}
  #ifdef __DJGPP__
-	free(path);
+	free(pn);
  #endif
  	if (err)
  		seterrno(err);
  	else
  		seterrno(oerrno);


--------------050100070406050505010309
Content-Type: text/x-patch;
 name="smake.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="smake.patch"

diff -aprNU5 smake-1.2.5.orig/lib/searchinpath.c smake-1.2.5/lib/searchinpath.c
--- smake-1.2.5.orig/lib/searchinpath.c	2010-11-18 22:49:52 +0000
+++ smake-1.2.5/lib/searchinpath.c	2018-01-07 02:20:18 +0000
@@ -125,10 +125,11 @@ searchfileinpath(name, mode, file_mode,
 #ifdef __DJGPP__
 	path = strdup(path);
 	if (path == NULL)
 		return (NULL);
 	strbs2s(path);	/* PATH under DJGPP can contain both slashes */
+	pn = path;	/* Remember PATH pointer */
 #endif
 
 	/*
 	 * A PATH name search should lead us to the path under which we
 	 * called the binary, but not necessarily to the install path as
@@ -146,11 +147,11 @@ searchfileinpath(name, mode, file_mode,
 		if ((np = searchonefile(name, mode,
 					(file_mode & SIP_PLAIN_FILE) != 0,
 					xn,
 					nbuf, np, ep)) != NULL) {
 #ifdef __DJGPP__
-			free(path);
+			free(pn);
 #endif
 			seterrno(oerrno);
 			return (np);
 		}
 		if (err == 0) {
@@ -161,11 +162,11 @@ searchfileinpath(name, mode, file_mode,
 		if (*path == '\0')
 			break;
 		path++;
 	}
 #ifdef __DJGPP__
-	free(path);
+	free(pn);
 #endif
 	if (err)
 		seterrno(err);
 	else
 		seterrno(oerrno);

--------------050100070406050505010309--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019