IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Opened 20 years ago

Closed 20 years ago

Last modified 20 years ago

#666 closed defect (fixed)

psMetadataConfigFormat does not handle arbitrary length input

Reported by: eugene Owned by: David.Robbins@…
Priority: high Milestone:
Component: types Version: 0.9.0
Severity: normal Keywords:
Cc:

Description

psMetadataConfigFormat uses fixed length strings for the individual lines (so-so
proble) and the total output string (big problem). this crashed writing the
header read in by a psFitsReadHeader (not surprising: the output string was
limited to 16000 chars, and the sample header I tried was 35000 chars...)

In exploring this bug, I took a close look at psMetadataConfigFormat, and it is
a bit of a mess:

  • would not need fixed length strings if it used psStringAppend instead of snprintf
  • does not make good use of local temporary variables for readabilty (eg, lots

of repeated entries like ((psTime*)(item->data.V))->... instead of writing
psTime *time = item->data.V once and referring to time)

  • In the vector output section, the values are written until a zero-value entry

is reached, as if the vectors were zero-value terminated!

  • the nested psMetadataConfigFormat call needs to handle a possible NULL return

value and return NULL (implied error in the lower level)

  • errors are causing memory leaks
  • the first block of code is fairly bizarre. I paste it here without further

comment:

type = item->type;
if ( type == PS_DATA_STRING) {

type = PS_DATA_STRING;

}
if ( type == PS_DATA_VECTOR) {

type = PS_DATA_VECTOR;

}
if ( type == PS_DATA_TIME) {

type = PS_DATA_TIME;

}
if ( item->type == PS_DATA_METADATA) {

type = PS_DATA_METADATA;

}
if (item == NULL) {

type = PS_DATA_UNKNOWN;

}

I have cleaned up this code and I will add it as an attachment

Attachments (1)

psMetadataConfigFormat.c (6.2 KB ) - added by eugene 20 years ago.
cleanup of psMetadataConfigFormat

Download all attachments as: .zip

Change History (3)

by eugene, 20 years ago

Attachment: psMetadataConfigFormat.c added

cleanup of psMetadataConfigFormat

comment:1 by robert.desonia@…, 20 years ago

Owner: changed from robert.desonia@… to David.Robbins@…

comment:2 by David.Robbins@…, 20 years ago

Resolution: fixed
Status: newclosed

Sorry about this one. Not sure what happened here. Only thought is that
multiple copies must have been confused before checking in to CVS. Anyway, I
merged the clean-up in and did some of my own cleanup too. (ie, added some
missing error checks, etc.) Looks good now.

Note: See TracTickets for help on using tickets.