Starlink / starlink

Starlink Software Collection
162 stars 53 forks source link

smf_check_smfHead has a problem #28

Closed timj closed 10 years ago

timj commented 10 years ago

smf_check_smfHead has this braindead logic:

    /* Detector names */
    if (ohdr->detname == NULL ){
      ohdr->detname = astMalloc( ihdr->ndet*
                                 ( strlen( ohdr->detname ) + 1 ) );
      if( ohdr->detname ) {
        memcpy( ohdr->detname, ihdr->detname,
                ihdr->ndet*( strlen( ohdr->detname ) + 1 ) );
      }
    }

    /* OCS Config */
    if (ohdr->ocsconfig == NULL ){
      ohdr->ocsconfig = astMalloc( ihdr->ndet*
                                   ( strlen( ohdr->ocsconfig ) + 1 ) );
      if( ohdr->ocsconfig ) {
        strcpy( ohdr->ocsconfig, ihdr->ocsconfig );
      }
    }

where the strlen call will obviously get itself into a bit of trouble given that we know that ohdr->ocsconfig is NULL. I imagine this is meant to be looking at ihdr and not ohdr but should presumably not do anything if ihdr->ocsconfig is itself NULL. I'm not sure why it's multiplying by ihdr->ndet.

It looks like the detname code from ddb48b7159eea582187c22385c87338731e77355 was copied for the ocsconfig case in c38a4374f49387dad26fed8a8bb70d038af489a4 (the detname section looks wrong as well).

dsberry commented 10 years ago

Should be fixed by commit c910faf40