Re: [Open Babel] REAL FIX: Atom charge lost in 2.3.x SDF-to-SMILES conversion

2012-05-18 Thread Craig James
Hi Paolo, On Thu, May 17, 2012 at 9:37 PM, Paolo Tosco wrote: > Dear Craig, > > if you read more carefully my post you will see I have *perfectly* clear > the difference between the size of a structure and the length of the > string. Using strncpy instead of strcpy is the first rule to avoid a

Re: [Open Babel] REAL FIX: Atom charge lost in 2.3.x SDF-to-SMILES conversion

2012-05-17 Thread Paolo Tosco
> My only worry is that the (char *)to parameter passed in has to be > long enough to hold the (char*)from parameter. I assume it is. > > Craig > Clearly this was also the concern of the original author, who, to avoid any assumption, decided to use strncpy to avoid buffer overflows. Simply he/

Re: [Open Babel] REAL FIX: Atom charge lost in 2.3.x SDF-to-SMILES conversion

2012-05-17 Thread Paolo Tosco
Dear Craig, if you read more carefully my post you will see I have *perfectly* clear the difference between the size of a structure and the length of the string. Using strncpy instead of strcpy is the first rule to avoid a buffer overflow - strcpy is deprecated by all good programming practic

Re: [Open Babel] REAL FIX: Atom charge lost in 2.3.x SDF-to-SMILES conversion

2012-05-17 Thread Craig James
Hi Paolo, I think you (and the original author) have mixed up the size of the structures with the length of the string. There's no need to do a sizeof() or to define a constant OB_ATOM_TYPE_LENGTH. Here's what I think is needed ... it's actually simpler than the original. Just use strcpy() inste

[Open Babel] REAL FIX: Atom charge lost in 2.3.x SDF-to-SMILES conversion

2012-05-17 Thread Paolo Tosco
Actually that sizeof in Translate (data.cpp) is plain wrong, since it refers to sizeof(char *) which is 8 on a 64-bit OS and 4 on a 32-bit OS; build the attached test.c with -m64 and -m32 and run to verify that: $ gcc -m64 test.c -o test64 $ ./test64 This is really 6: 6 This is machine-dependen