90dc829b2d87b15c4fc4bbc1d814f83d1274ef52 braney Fri Sep 4 14:00:05 2026 -0700 Pass element counts, not byte sizes, to the chop routines chopByWhite, chopString and chopByChar take their last argument as a count of elements in the output array. Fifteen call sites passed sizeof(array) instead. For an array of pointers that is eight times the real capacity on a 64-bit build, so the chop could write well past the end of the array. Switched each to ArraySize(). Behaviour is unchanged for any input that already fitted in the array. Built clean: lib, hg/lib, hg/hgTracks, hg/hgc, hg/utils/hubCheck, utils/bedScore, parasol/lib, parasol/parasol. Three directories do not build, but they fail the same way without this change: checkExp is missing htslib link flags, and cgapSageFind and affySplice have stale prototypes in files this does not touch. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> diff --git src/hg/utils/hubCheck/hubCheck.c src/hg/utils/hubCheck/hubCheck.c index 2ec999e3bd1..40772876f2e 100644 --- src/hg/utils/hubCheck/hubCheck.c +++ src/hg/utils/hubCheck/hubCheck.c @@ -818,31 +818,31 @@ if (i > 0) dyStringAppend(msg, ", "); dyStringAppend(msg, VALID_TRACK_TYPES[i]); } return dyStringCannibalize(&msg); } boolean checkTypeLine(struct trackHubGenome *genome, struct trackDb *tdb, struct dyString *errors, struct trackHubCheckOptions *options) { boolean retVal = FALSE; struct errCatch *errCatch = errCatchNew(); if (errCatchStart(errCatch)) { char *type = trackDbRequiredSetting(tdb, "type"); char *splitType[4]; - int numWords = chopByWhite(cloneString(type), splitType, sizeof(splitType)); + int numWords = chopByWhite(cloneString(type), splitType, ArraySize(splitType)); char *trackType = splitType[0]; boolean isParentTrack = (tdbIsComposite(tdb) || tdbIsCompositeView(tdb) || tdbIsContainer(tdb)); if (!isParentTrack && !isValidTrackType(trackType)) { errAbort("error: unrecognized type \"%s\" for track \"%s\". Valid types are: %s. " "See https://genome.ucsc.edu/goldenPath/help/trackDb/trackDbHub.html#type for the more incornation list.", trackType, tdb->track, getValidTrackTypesMsg()); } if (sameString(splitType[0], "bigBed")) { if (numWords > 1 && (strchr(splitType[1], '+') || strchr(splitType[1], '.'))) { errAbort("error in type line \"%s\" for track \"%s\". " "A space is needed after the \"+\" or \".\" character.", type, tdb->track);