Hi,

Please try the attached patch and let me know if it works for you. 

-jon

On 3/8/20 1:44 AM, Edmond Orignac wrote:
>
> I hope I am not wasting too much of your time with this, but I have
> tested the XmTextGetString x $WIDGET function of dtksh on a 32bit
> Intel computer running Slackware 14.2. I have found that there was no
> core dumps when calling this function contrarily to the case of Ubuntu
> 18.04 on 64 bit Intel . This was with the same CDE 2.3.1a (devel)
> version with the same fr_FR.UTF-8 locale on both systems. The only
> obvious difference is that Slackware uses Motif 2.3.5 while Ubuntu has
> Motif 2.3.8. 
>
> I was probably wrong to worry about a regression. It is more likely
> that XmTextGetString works well on 32bit Intel but has some issue with
> 64bit Intel.  
>
>
> Le 01/03/2020 à 02:36, Jon Trulson a écrit :
>> On 2/29/20 4:38 AM, Edmond Orignac wrote:
>>> I have noticed something that seems odd with the functions
>>> XmTextGetString and XmTextFieldGetString.
>>>
>>> When these functions are called to read the text typed in an XmText
>>> widget, they cause a segmentation fault. However, using XtGetValues
>>> instead avoids the segmentation fault.
>>>
>>> I have the impression this is a new behavior as I have a script that
>>> was using XmTextGetString that was not segfaulting in the previous
>>> versions of CDE. This does not seem locale related, segmentation fault
>>>
>>> happens both with the fr_FR and the C locales.
>>>
>>> Am I misusing these functions or is it a regression in dtksh ?
>>>
>>
>> I can't say whether this is a regression or not...  What version
>> works?  Which version does not?  Can you bisect it?
>>
>>
>> -- 
>> Jon Trulson
>>
>>   "Entropy.  It isn't what it used to be."
>>                            -- Sheldon
>>
>>
>> _______________________________________________
>> cdesktopenv-devel mailing list
>> cdesktopenv-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel

-- 
Jon Trulson

  "Entropy.  It isn't what it used to be."
                           -- Sheldon

>From 4750c85c095069dfc6d4532c3584da94fab18ec9 Mon Sep 17 00:00:00 2001
From: Jon Trulson <j...@radscan.com>
Date: Sun, 8 Mar 2020 15:05:48 -0600
Subject: [PATCH] dtksh: fix 32b/64b issues with XmTextGetString and
 XmTextFieldGetString

Some of these functions were returning pointers cast as integers,
which of course is bad on a 64b LP_64 systems.

This code should probably just be refactored at some point.  There may
be other hidden issues, and all the casting just sucks.
---
 cde/programs/dtksh/xmcmds.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/cde/programs/dtksh/xmcmds.c b/cde/programs/dtksh/xmcmds.c
index e3f1e8bd..ff6b6e81 100644
--- a/cde/programs/dtksh/xmcmds.c
+++ b/cde/programs/dtksh/xmcmds.c
@@ -171,7 +171,7 @@ static int Text_Widget(
                         int argc,
                         char *argv[]) ;
 static int Text_VarAndWidget( 
-                        int (*func)(Widget w),
+                        long (*func)(Widget w),
                         Boolean varIsString,
                         int argc,
                         char *argv[]) ;
@@ -1301,7 +1301,7 @@ do_DtHelpReturnSelectedWidgetId(
 	return(1);
    }
 
-   res = DtHelpReturnSelectedWidgetId(w->w, NULL, &retWidget);
+   res = DtHelpReturnSelectedWidgetId(w->w, 0, &retWidget);
    XSync(XtDisplay(w->w), False);
 
    f.addr = (caddr_t)&res;
@@ -3959,7 +3959,7 @@ do_XmTextRemove(
 
 static int
 Text_VarAndWidget(
-        int (*func)(Widget w),
+        long (*func)(Widget w),
         Boolean varIsString,
         int argc,
         char *argv[] )
@@ -4008,7 +4008,7 @@ do_XmTextGetTopCharacter(
         int argc,
         char *argv[] )
 {
-   return (Text_VarAndWidget((int (*)())XmTextGetTopCharacter, False, argc, 
+   return (Text_VarAndWidget((long (*)())XmTextGetTopCharacter, False, argc, 
            argv));
 }
 
@@ -4018,7 +4018,7 @@ do_XmTextGetBaseline(
         int argc,
         char *argv[] )
 {
-   return (Text_VarAndWidget(XmTextGetBaseline, False, argc, argv));
+    return (Text_VarAndWidget((long (*)())XmTextGetBaseline, False, argc, argv));
 }
 
 
@@ -4027,7 +4027,7 @@ do_XmTextGetInsertionPosition(
         int argc,
         char *argv[] )
 {
-   return (Text_VarAndWidget((int (*)())XmTextGetInsertionPosition, False, 
+   return (Text_VarAndWidget((long (*)())XmTextGetInsertionPosition, False, 
            argc, argv));
 }
 
@@ -4037,7 +4037,7 @@ do_XmTextGetLastPosition(
         int argc,
         char *argv[] )
 {
-   return (Text_VarAndWidget((int (*)())XmTextGetLastPosition, False, argc, 
+   return (Text_VarAndWidget((long (*)())XmTextGetLastPosition, False, argc, 
                              argv));
 }
 
@@ -4047,7 +4047,7 @@ do_XmTextGetMaxLength(
         int argc,
         char *argv[] )
 {
-   return (Text_VarAndWidget(XmTextGetMaxLength, False, argc, argv));
+   return (Text_VarAndWidget((long (*)())XmTextGetMaxLength, False, argc, argv));
 }
 
 
@@ -4056,7 +4056,7 @@ do_XmTextGetSelection(
         int argc,
         char *argv[] )
 {
-   return (Text_VarAndWidget((int (*)())XmTextGetSelection, True, argc, argv));
+   return (Text_VarAndWidget((long (*)())XmTextGetSelection, True, argc, argv));
 }
 
 
@@ -4065,7 +4065,7 @@ do_XmTextGetString(
         int argc,
         char *argv[] )
 {
-   return (Text_VarAndWidget((int (*)())XmTextGetString, True, argc, argv));
+   return (Text_VarAndWidget((long (*)())XmTextGetString, True, argc, argv));
 }
 
 
-- 
2.17.1

_______________________________________________
cdesktopenv-devel mailing list
cdesktopenv-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel

Reply via email to