SUMMARY: libg++ (2.6.2) problem

From: Geordie Klueber <gfkpci_at_borg.cis.rit.edu>
Date: Tue, 7 Feb 95 17:23:47 -0500

About 3 minutes after my posting, a super-nova exploded inside my head and
I figured out my problem. For anyone building libg++ (version 2.6.2) on the
OSF/1 platform, you'll want to take notice of this solution.

In the file libio/iosscanf.c, look at the function header for the _IO_sscanf
function. In the argument declaration for the NON-ANSI C case, the type of
the "string" argument is NOT defined. As a result, the type defaults to
"int", which is 32-bits on the Alpha (and most other architectures). Since
the Alpha is a 64-bit machine, the result is that any function calling
the _IO_sscanf function is likely to cause a segmentation violation due to
the truncation of the pointer to the "string" buffer.

In my file, the problem is on line 38. Here's what the code WAS:

#ifdef __STDC__
  (const char * string, const char* format, ...)
#else
(string, format, va_alist) char *format; va_dcl
#endif

                           ^^^^^^^^^^^^^^^^^^^^
Note that there is no type declaration for the "string" argument.
Now, here's what the code SHOULD be:

#ifdef __STDC__
  (const char * string, const char* format, ...)
#else
(string, format, va_alist) char *string; char *format; va_dcl
#endif

Once I made this change, I just recompiled, rebuilt the library and
the test programs and all was well.

IF YOU MISS THIS FIX, ANYONE USING THE sscanf(3) FUNCTION IS LIKELY TO
RUN INTO PROBLEMS! Caveat Emptor... :-)

Hope this helps someone else out there... :-)

-- Geordie
Received on Tue Feb 07 1995 - 17:21:19 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:45 NZDT