bugGNUstep - Bugs: bug #35669, Garbage description string in...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #35669: Garbage description string in POSIX NSErrors

Submitted by:  Jens Alfke <snej>
Submitted on:  Wed 29 Feb 2012 07:42:47 PM UTC  
 
Category: Base/FoundationSeverity: 3 - Normal
Item Group: BugStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: In Test

Thu 01 Mar 2012 07:35:31 PM UTC, comment #1:

Should have been fixed by ensuring _GNU_SOURCE is not defined.
Please try it.

Richard Frith-Macdonald <CaS>
Project Member
Wed 29 Feb 2012 07:42:47 PM UTC, original submission:

I am getting NSErrors with garbage description strings back from NSFileManager. (To be clear: the error is expected, and the domain and code are correct, but the description string in the userInfo is a large block of garbage.)

The cause appears to be a bug in +[NSError _lastError] in NSError+GNUstepBase.m. It calls strerror_r to get an error message, but that call isn’t filling in the char[] buffer.

Reading the man page tells me that there are two versions of strerror_r (a GNU one and a POSIX one) with different return types — the GNU version returns the string its return value and doesn’t always copy it into the buffer. What seems to be happening is that the method thinks it’s calling the POSIX version, but it’s actually calling the GNU version. So the error message in the return value is ignored, and instead it uses the buffer which wasn’t initialized.

I’m not sure what the best way is to fix this. It looks like one could either add
#undef _GNU_SOURCE
near the top of the file where it defines _XOPEN_SOURCE; or one could use an #if around the call to strerror_r to call either version depending on which one is available.

I have experimentally tried the latter, adding code that uses the non-POSIX version of strerror_r, and that fixes the problem.

CONFIGURATION

URL: http://svn.gna.org/svn/gnustep/libs/base/trunk/Source
Repository Root: http://svn.gna.org/svn/gnustep
Repository UUID: 72102866-910b-0410-8b05-ffd578937521
Revision: 34837

My OS is Ubuntu 11 (current according to software update).
I'm compiling with Clang 3.1 (trunk 151546).

Jens Alfke <snej>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by CaS (Posted a comment)
  • -unavailable- added by snej (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 01 Mar 2012 07:35:31 PM UTCCaSStatusNone=>Fixed
      Open/ClosedOpen=>In Test

    Back to the top


    Powered by Savane 3.1-cleanup1