Bug 12897 - XGetIMValues doesn't return the name of the first argument that could not be obtained
Summary: XGetIMValues doesn't return the name of the first argument that could not be ...
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Lib/Xlib (show other bugs)
Version: 7.5 (2009.10)
Hardware: All All
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard: 2011BRB_Reviewed
Keywords: i18n, patch
Depends on:
Blocks:
 
Reported: 2007-10-23 09:17 UTC by Yann Droneaud
Modified: 2011-10-11 09:59 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Return p->name instead of p->value (untested) (1.19 KB, patch)
2007-10-23 09:20 UTC, Yann Droneaud
no flags Details | Splinter Review
Working test case for XGetIMValues() (3.06 KB, text/plain)
2010-12-19 09:13 UTC, Yann Droneaud
no flags Details

Description Yann Droneaud 2007-10-23 09:17:37 UTC
While trying to use XIM, I found that calling XGetIMValues 
with unknown names like:

err = XGetIMValues(im, "invalid", &arg, NULL);

return address of &arg, instead of the address of name "invalid" 
as stated in man page (XOpenIM) and Xlib documentation (chapter 13.5.3) : 

"otherwise, it returns the name of the first argument that could not
be obtained."

In modules/im/ximcp/imRm.c: _XimGetIMValueData() 
the function returns p->value instead of p->name .

And according to the code in imRm.c, _XimSetIMValueData() 
has the same problem.
Comment 1 Yann Droneaud 2007-10-23 09:20:20 UTC
Created attachment 12164 [details] [review]
Return p->name instead of p->value (untested)

Here is a little patch to change p->value to p->name in 
_XimSetIMValueData() and _XimGetIMValueData()
Comment 2 Yann Droneaud 2007-10-23 09:24:42 UTC
My original program does the following:

    char *name;

    static const char *invalid = "INVALID";

    void *arg = (void *) 0x004c754e; /* "NuL" on i386 arch */

    XIMValuesList *imvl = NULL;
    XIMStyles *ims = NULL;

    /* retrieve some values, and get an error */
    name = XGetIMValues(im, 
			XNQueryIMValuesList, &imvl, 
			XNQueryInputStyle, &ims,
			invalid, &arg, 
			NULL);
    if (name != NULL) {
      /* 
       * name should point to the name 
       * which was not retrieved, eg. "INVALID"
       */
      printf("XGetIMValues() returned: %p '%s'\n"
	     "invalid name: %p '%s'\n"
	     "invalid arg:  %p\n", 
	     name, name, 
	     invalid, invalid, 
	     &arg);
    }

And print:

XGetIMValues() returned: 0xbf8d1d34 'NuL'
invalid name: 0x8048adf 'INVALID'
invalid arg:  0xbf8d1d34


Comment 3 Jesse Adkins 2010-12-10 15:23:06 UTC
(In reply to comment #2)
This doesn't compile. Can you an example that compiles so I can check to see if this is still an issue?
Comment 4 Yann Droneaud 2010-12-19 09:13:59 UTC
Created attachment 41259 [details]
Working test case for XGetIMValues()

(In reply to comment #3)
> This doesn't compile. Can you an example that compiles so I can check to see if
> this is still an issue?

Here's a complete test case which demonstrate the problem:

  $ gcc -Wall -Wextra test-XGetIMValues.c -o test-XGetIMValues -lX11 
  $ ./test-XGetIMValues 
  XLib support current locale
  Current locale modifier '@im=none'
  XGetIMValues() returned: 0x7fff220d5628 'NuL'
        invalid name was : 0x400db8 'INVALID'
        invalid arg  was : 0x7fff220d5628
  ERROR: XGetIMValues() returned address of argument instead of its name
  ERROR: valid function return would be: 0x400db8 'INVALID'

As you can see XGetIMValues() returns the argument and not its name.

XGetIMValues() man page :

  The XGetIMValues function presents a variable argument list programming 
  interface for querying properties or features of the specified input method.  
  This function returns NULL if it succeeds; otherwise, it returns the name of 
  the first argument that could not be obtained.
Comment 5 Yann Droneaud 2010-12-19 09:17:58 UTC
(In reply to comment #4)

It was tested on Fedora Core 14 against libX11 1.3.4.
Comment 6 Jeremy Huddleston Sequoia 2011-10-08 19:39:53 UTC
Can you please send your patch to xorg-devel for review?

Thanks.
Comment 7 Jeremy Huddleston Sequoia 2011-10-11 09:59:33 UTC
Pushed the fix, thanks.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.