|
From: David E. <tw...@us...> - 2004-04-20 16:58:59
|
On Tue, 2004-04-20 at 17:20, Jim Amrhein wrote:
> Hi , I'm new to valgrind.
> My setup :
> Redhat 9
> gcc -v
> Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2.2/specs
> Configured with: ./configure
> Thread model: posix
> gcc version 3.2.2
>
> Valgrind version valgrind-2.0.0
>
> The code :
>
>
> outfile = (char *)malloc(100);
>
> (void) strncpy (outfile, infile_backup,len);
>
> jfif_name = (char *) malloc(100);
>
> Line 72: (void) strcpy(jfif_name, outfile );
>
>
> The errors:
> ==16656== 1 errors in context 1 of 2:
> ==16656== Conditional jump or move depends on uninitialised value(s)
> ==16656== at 0x40022F2C: strlen (mac_replace_strmem.c:164)
> ==16656== by 0x4048F00D: _IO_vfprintf_internal (in /lib/libc-2.3.2.so)
> ==16656== by 0x404A9F6B: _IO_vsprintf_internal (in /lib/libc-2.3.2.so)
> ==16656== by 0x404973CC: __GI_sprintf (in /lib/libc-2.3.2.so)
> ==16656==
> ==16656== 1 errors in context 2 of 2:
> ==16656== Conditional jump or move depends on uninitialised value(s)
> ==16656== at 0x40022F55: strcpy (mac_replace_strmem.c:173)
> ==16656== by 0x804B311: hdfconverter (hdfconverter.c:72)
> ==16656== by 0x804E4EF: Process8BitImages (sendbrowse.c:1436)
> ==16656== by 0x804C612: main (sendbrowse.c:343)
> ==16656== IN SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
>
> I've printed out outfile so there is data there.
> The data is way less than 100 characters.
>
>
> Not sure what I'm missing.
I think that if strlen(infile_backup) >= len then outfile will not
become null-terminated by the call to strncpy(), so you should add
outfile[len] = '\0' or similar. See the strncpy man page for details.
--
Regards,
-\- David Eriksson -/-
SynCE - http://synce.sourceforge.net
CalcEm - http://calcem.sourceforge.net
ScummVM - http://scummvm.sourceforge.net
Desquirr - http://desquirr.sourceforge.net
SetiWrapper - http://setiwrapper.sourceforge.net
|