Untrusted-input and legacy-subsystem hardening audit (WP-43)
This note records the WP-43 input-validation, integer-overflow, and
allocation/teardown-lifetime audit across the UIL binary database loader
(clients/uil/UilDB.c), WML generator (tools/wml), the remaining legacy
first-party modules in lib/Xm, lib/Mrm, and clients/mwm, and the
October/November 2026 image, appearance, scaling, text, and accessibility
subsystems.
Summary of defects fixed
- UIL WMD binary database loader (
clients/uil/UilDB.c):db_incorporate()now verifiesdbfile != NULLafterdb_open_file()and beforefclose(dbfile), preventing a nullFILE *dereference if diagnostic handling returns without a long jump.db_read_ints_and_string()validatesheader->num_itemsandheader->table_sizebefore callingXtCalloc(1, (Cardinal)header->table_size)so a negativetable_sizecannot wrap to aUINT_MAXallocation, rejects negativetable[i].b_length, and verifies that each entry instring_tableis NUL-terminated atstring_table[table[i].b_length].db_read_length_and_string()verifies that each non-empty string instring_tableis NUL-terminated atstring_table[lengths[i] - 1]before comparing against"user_defined"or publishing the pointer into UIL symbol tables, and explicitly clearstable[i] = NULLwhenlengths[i] == 0.db_read_int_and_shorts()explicitly clearstable[i].values = NULLwhentable[i].values_cnt == 0so raw bytes read from a damaged.wmdfile cannot leave a non-null forged pointer in an empty enum set descriptor.
- First-party legacy modules (
lib/Xm,lib/Mrm,clients/mwm):lib/Xm/ReadImage.c(_XmReadImageAndHotSpotFromFile): rejects nulldisplayorfilenameinputs and freesXReadBitmapFileData'sdatabuffer withXFree(data)when_XmCreateImagefails.lib/Xm/AtomMgr.c(XmInternAtom,XmGetAtomName): guards nulldisplay, nullname, andNoneatoms before calling Xlib.lib/Xm/CvtUnit.c(XmCvtStringToUnitType): guards nullfrom_val,to_val, defaultDisplay, andXmDisplaywidget before callingXtConvertAndStore.lib/Xm/Dest.c(_XmSetDestination,XmGetDestination): guards nullDisplaypointers and checksdd->display.displayInfo != NULLduring display teardown.lib/Xm/DialogSE.c(DeleteWindowHandler,GetManagedKid): guards null widget, closure, and composite child-list pointers.lib/Xm/DrHiDash.c(_XmDrawHighlight) andlib/Xm/DrPoly.c(XmeDrawPolygonShadow): guard nullDisplay,Drawable,GC, andXPointpointers, non-positive dimensions/counts, and nullXPolygonRegionreturns.lib/Xm/FocusAct.c(_XmMenuButtonTakeFocus,_XmMenuButtonTakeFocusUp): guards nullwid,XtDisplay(wid), andeventpointers.lib/Xm/GetRes.c(XmGetSecondaryResourceData): initializes*secondaryDataRtn = NULLand rejects nullw_classor output pointers.lib/Xm/IconH.c(GetContainerParent,XmCreateIconHeader): guards nullwidandparentpointers.lib/Xm/ObsoXme.c(_XmVirtualToActualKeysym,_XmResizeObject,_XmMoveObject): guards null display, output, and widget pointers.lib/Xm/ShellE.c(StructureNotifyHandler): guards null widget, closure, event,xmScreen, andcontinue_to_dispatchpointers, and prevents unsigned underflow ofxmScreen->screen.numReparented.lib/Xm/TearOffB.c(HeightDefault,Redisplay,BDrag,BActivate,KActivate): guards unsignedDimensionsubtraction whenwidth <= 2 * highlight_thicknessorheight <= 2 * highlight_thickness, and checks parent andXmQTmenuSystemtrait pointers before dispatch.lib/Xm/TravAct.c(_XmGetFocusFlag,_XmSetFocusFlag,_XmTrackShellFocus): guards null widget, display,displayInfo, closure, event, anddontSwallowpointers.lib/Xm/ValTime.c(_XmValidTimestamp): guards nullw,XtDisplay(w), shell-parent walk, and unrealizedXtWindow(w) == Noneso an unrealized hierarchy returnsCurrentTimeinstead of blocking inXWindowEvent.lib/Mrm/Mrmlwrite.c,lib/Mrm/Mrmwwrite.c, andlib/Mrm/Mrmos.c: validate non-empty resource index strings before mutating context group metadata and guard null float/double conversion pointers.clients/mwm/WmCPlace.c(SetupPlacement,IsRepeatedKeyEvent,DoPlacement): guards null client/event pointers and prevents unsigned underflow when subtracting frame offsets fromplaceWidth/placeHeight.
- October/November 2026 subsystems (
lib/Xm/Png.c,lib/Xm/Jpeg.c,lib/Xm/AppearanceDraw.c):lib/Xm/Png.c(_XmPngGetImage): guards nullscreen,infile, andximagearguments and boundsimage_width,image_height, andimage_rowbytesagainstINT_MAXandimage_channels(3or4) beforeXCreateImageandpng_process_image.lib/Xm/Jpeg.c(load_jpeg,_XmJpegGetImage): guards nullscreen,infile, andximagearguments, requestsJCS_RGBdecompression for non-grayscale color spaces (such as CMYK/YCCK JPEGs), and verifiescinfo.output_componentsis1or3so scanline reads into 3-byteCTableentries cannot overflow*image_data.lib/Xm/AppearanceDraw.c(_XmAppearanceRoundedRectangleRegion,_XmAppearanceDrawButtonFocus,_XmAppearanceDrawButton,_XmAppearanceDrawPickerFrame): checksXCreateRegion()returns forNULLbefore union/subtraction/destruction and guards picker chevronxcoordinates against negative offsets on narrow widgets.
Validation
tests/automated/check-untrusted-input-audit-wp43.py verifies the source
contracts across all audited files and compiles and runs an AddressSanitizer +
UndefinedBehaviorSanitizer harness exercising the null, bounds, and malformed
WMD/image entry points.
CK Core Motif