$OpenBSD: patch-src_motif_xmcombo_xmcombo_c,v 1.1.1.1 2004/07/16 21:01:36 todd Exp $ --- src/motif/xmcombo/xmcombo.c.orig Sun Sep 22 06:53:58 2002 +++ src/motif/xmcombo/xmcombo.c Wed Apr 30 15:15:48 2003 @@ -2224,11 +2224,11 @@ static void MotionVerifyCallback(Widget * Bastele einen vollstaendigen Namens- und Klassenbezeichner anhand * des angegebenen Widgets zusammen. */ -static void MakeNameAndClass(Widget w, char *NameBuff, char *ClassBuff) +static void MakeNameAndClass(Widget w, char *NameBuff, size_t NameBuffLen, char *ClassBuff, size_t ClassBuffLen) { Widget Parent = XtParent(w); - if ( Parent ) MakeNameAndClass(Parent, NameBuff, ClassBuff); + if ( Parent ) MakeNameAndClass(Parent, NameBuff, NameBuffLen, ClassBuff, ClassBuffLen); if ( XtIsSubclass(w, applicationShellWidgetClass) ) { /* Wenn wir ganz oben angekommen sind, holen wir uns den * Namen und die Klasse der Applikation selbst und nicht die @@ -2237,16 +2237,16 @@ static void MakeNameAndClass(Widget w, c String AppName, AppClass; XtGetApplicationNameAndClass( XtDisplayOfObject(w), &AppName, &AppClass); - strcpy(NameBuff, AppName); - strcpy(ClassBuff, AppClass); + strlcpy(NameBuff, AppName, NameBuffLen); + strlcpy(ClassBuff, AppClass, ClassBuffLen); } else { /* Ansonsten sind wir noch mitten irgendwo in der Hierarchie * und besorgen uns den Namen und die Klasse dieses Widgets */ - strcat(NameBuff, "."); - strcat(NameBuff, XtName(w)); - strcat(ClassBuff, "."); - strcat(ClassBuff, ((CoreClassRec *) XtClass(w))->core_class.class_name); + strlcat(NameBuff, ".", NameBuffLen); + strlcat(NameBuff, XtName(w), NameBuffLen); + strlcat(ClassBuff, ".", NameBuffLen); + strlcat(ClassBuff, ((CoreClassRec *) XtClass(w))->core_class.class_name, NameBuffLen); } } /* MakeNameAndClass */ @@ -2256,7 +2256,8 @@ static void MakeNameAndClass(Widget w, c * noch in das gewuenschte Zielformat konvertiert werden. */ static Boolean FetchResource(Widget w, - char *FullName, char *FullClass, + char *FullName, size_t FullNameLen, + char *FullClass, size_t FullClassLen, char *RscName, char *RscClass, XrmValue *RscValue, String *RepresentationType) @@ -2265,8 +2266,10 @@ static Boolean FetchResource(Widget w, char *EndOfName = FullName + strlen(FullName); char *EndOfClass = FullClass + strlen(FullClass); - strcat(FullName, "."); strcat(FullName, RscName); - strcat(FullClass, "."); strcat(FullClass, RscClass); + strlcat(FullName, ".", FullNameLen); + strlcat(FullName, RscName, FullNameLen); + strlcat(FullClass, ".", FullClassLen); + strlcat(FullClass, RscClass, FullClassLen); ok = XrmGetResource( XtDatabase(XtDisplayOfObject(w)), FullName, FullClass, RepresentationType, RscValue); @@ -2291,14 +2294,15 @@ static Boolean FetchResource(Widget w, * String --> KeySym */ static Boolean FetchIntResource(Widget w, - char *FullName, char *FullClass, + char *FullName, size_t FullNameLen, + char *FullClass, size_t FullClassLen, char *RscName, char *RscClass, int *pInt) { XrmValue RscValue, RscDest; String RepresentationType; - if ( FetchResource(w, FullName, FullClass, + if ( FetchResource(w, FullName, FullNameLen, FullClass, FullClassLen, RscName, RscClass, &RscValue, &RepresentationType) ) { RscDest.size = sizeof(int); @@ -2311,14 +2315,15 @@ static Boolean FetchIntResource(Widget w } /* FetchIntResource */ static Boolean FetchShortResource(Widget w, - char *FullName, char *FullClass, + char *FullName, size_t FullNameLen, + char *FullClass, size_t FullClassLen, char *RscName, char *RscClass, short *pShort) { XrmValue RscValue, RscDest; String RepresentationType; - if ( FetchResource(w, FullName, FullClass, + if ( FetchResource(w, FullName, FullNameLen, FullClass, FullClassLen, RscName, RscClass, &RscValue, &RepresentationType) ) { RscDest.size = sizeof(short); @@ -2331,14 +2336,15 @@ static Boolean FetchShortResource(Widget } /* FetchShortResource */ static Boolean FetchLabelTypeResource(Widget w, - char *FullName, char *FullClass, + char *FullName, size_t FullNameLen, + char *FullClass, size_t FullClassLen, char *RscName, char *RscClass, unsigned char *pUChar) { XrmValue RscValue; String RepresentationType; - if ( FetchResource(w, FullName, FullClass, + if ( FetchResource(w, FullName, FullNameLen, FullClass, FullClassLen, RscName, RscClass, &RscValue, &RepresentationType) ) { if ( strcasecmp((char *) RscValue.addr, "XmPIXMAP") == 0 ) @@ -2351,14 +2357,15 @@ static Boolean FetchLabelTypeResource(Wi } /* FetchLabelTypeResource */ static Boolean FetchDimensionResource(Widget w, - char *FullName, char *FullClass, + char *FullName, size_t FullNameLen, + char *FullClass, size_t FullClassLen, char *RscName, char *RscClass, Dimension *pDimension) { XrmValue RscValue, RscDest; String RepresentationType; - if ( FetchResource(w, FullName, FullClass, + if ( FetchResource(w, FullName, FullNameLen, FullClass, FullClassLen, RscName, RscClass, &RscValue, &RepresentationType) ) { RscDest.size = sizeof(Dimension); @@ -2371,14 +2378,15 @@ static Boolean FetchDimensionResource(Wi } /* FetchDimensionResource */ static Boolean FetchStringResource(Widget w, - char *FullName, char *FullClass, + char *FullName, size_t FullNameLen, + char *FullClass, size_t FullClassLen, char *RscName, char *RscClass, String *pString) { XrmValue RscValue; String RepresentationType; - if ( FetchResource(w, FullName, FullClass, + if ( FetchResource(w, FullName, FullNameLen, FullClass, FullClassLen, RscName, RscClass, &RscValue, &RepresentationType) ) { *pString = (char *) RscValue.addr; @@ -2388,14 +2396,15 @@ static Boolean FetchStringResource(Widge } /* FetchStringResource */ static Boolean FetchKeySymResource(Widget w, - char *FullName, char *FullClass, + char *FullName, size_t FullNameLen, + char *FullClass, size_t FullClassLen, char *RscName, char *RscClass, KeySym *pKeySym) { XrmValue RscValue, RscDest; String RepresentationType; - if ( FetchResource(w, FullName, FullClass, + if ( FetchResource(w, FullName, FullNameLen, FullClass, FullClassLen, RscName, RscClass, &RscValue, &RepresentationType) ) { RscDest.size = sizeof(KeySym); @@ -2408,14 +2417,15 @@ static Boolean FetchKeySymResource(Widge } /* FetchKeySymResource */ static Boolean FetchXmStringResource(Widget w, - char *FullName, char *FullClass, + char *FullName, size_t FullNameLen, + char *FullClass, size_t FullClassLen, char *RscName, char *RscClass, XmString *pString) { XrmValue RscValue; String RepresentationType; - if ( FetchResource(w, FullName, FullClass, + if ( FetchResource(w, FullName, FullNameLen, FullClass, FullClassLen, RscName, RscClass, &RscValue, &RepresentationType) ) { *pString = XmCvtCTToXmString((char *) RscValue.addr); @@ -2425,7 +2435,8 @@ static Boolean FetchXmStringResource(Wid } /* FetchXmStringResource */ static Boolean FetchXmStringTableResource(Widget w, - char *FullName, char *FullClass, + char *FullName, size_t FullNameLen, + char *FullClass, size_t FullClassLen, char *RscName, char *RscClass, XmStringTable *pStringTable, int *pTableSize) @@ -2435,7 +2446,7 @@ static Boolean FetchXmStringTableResourc String TmpList, p, pStart; int Entries, Entry; - if ( FetchResource(w, FullName, FullClass, + if ( FetchResource(w, FullName, FullNameLen, FullClass, FullClassLen, RscName, RscClass, &RscValue, &RepresentationType) ) { /* @@ -2474,14 +2485,15 @@ static Boolean FetchXmStringTableResourc } /* FetchXmStringTableResource */ static Boolean FetchXmFontListResource(Widget w, - char *FullName, char *FullClass, + char *FullName, size_t FullNameLen, + char *FullClass, size_t FullClassLen, char *RscName, char *RscClass, XmFontList *pFontList) { XrmValue RscValue, RscDest; String RepresentationType; - if ( FetchResource(w, FullName, FullClass, + if ( FetchResource(w, FullName, FullNameLen, FullClass, FullClassLen, RscName, RscClass, &RscValue, &RepresentationType) ) { RscDest.size = sizeof(XmFontList); @@ -2494,14 +2506,15 @@ static Boolean FetchXmFontListResource(W } /* FetchXmFontListResource */ static Boolean FetchPixmapResource(Widget w, - char *FullName, char *FullClass, + char *FullName, size_t FullNameLen, + char *FullClass, size_t FullClassLen, char *RscName, char *RscClass, Pixmap *pPixmap) { XrmValue RscValue, RscDest; String RepresentationType; - if ( FetchResource(w, FullName, FullClass, + if ( FetchResource(w, FullName, FullNameLen, FullClass, FullClassLen, RscName, RscClass, &RscValue, &RepresentationType) ) { RscDest.size = sizeof(Pixmap); @@ -2588,13 +2601,14 @@ static void InitMirrorResources(XmComboB int i, size = XtNumber(ResourceMirror); FullName[0] = 0; FullClass[0] = 0; - MakeNameAndClass((Widget) w, FullName, FullClass); + MakeNameAndClass((Widget) w, FullName, sizeof(FullName), FullClass, sizeof(FullClass)); for ( i=0; i < size; i++ ) { switch ( ResourceMirror[i].Converter ) { case RInt: if ( FetchIntResource((Widget) w, - FullName, FullClass, + FullName, sizeof(FullName), + FullClass, sizeof(FullClass), ResourceMirror[i].Name, ResourceMirror[i].Class, &AInt) ) XtVaSetValues((Widget) w, ResourceMirror[i].Name, @@ -2602,7 +2616,8 @@ static void InitMirrorResources(XmComboB break; case RXmItemCount: if ( FetchIntResource((Widget) w, - FullName, FullClass, + FullName, sizeof(FullName), + FullClass, sizeof(FullClass), ResourceMirror[i].Name, ResourceMirror[i].Class, &AInt) && ( AInt != 0) ) XtVaSetValues((Widget) w, ResourceMirror[i].Name, @@ -2610,7 +2625,8 @@ static void InitMirrorResources(XmComboB break; case RShort: if ( FetchShortResource((Widget) w, - FullName, FullClass, + FullName, sizeof(FullName), + FullClass, sizeof(FullClass), ResourceMirror[i].Name, ResourceMirror[i].Class, &AShort) ) XtVaSetValues((Widget) w, ResourceMirror[i].Name, @@ -2618,7 +2634,8 @@ static void InitMirrorResources(XmComboB break; case RLType: if ( FetchLabelTypeResource((Widget) w, - FullName, FullClass, + FullName, sizeof(FullName), + FullClass, sizeof(FullClass), ResourceMirror[i].Name, ResourceMirror[i].Class, &AUChar) ) XtVaSetValues((Widget) w, ResourceMirror[i].Name, @@ -2626,7 +2643,8 @@ static void InitMirrorResources(XmComboB break; case RDimension: if ( FetchDimensionResource((Widget) w, - FullName, FullClass, + FullName, sizeof(FullName), + FullClass, sizeof(FullClass), ResourceMirror[i].Name, ResourceMirror[i].Class, &ADimension) ) XtVaSetValues((Widget) w, ResourceMirror[i].Name, @@ -2634,7 +2652,8 @@ static void InitMirrorResources(XmComboB break; case RXmString: if ( FetchXmStringResource((Widget) w, - FullName, FullClass, + FullName, sizeof(FullName), + FullClass, sizeof(FullClass), ResourceMirror[i].Name, ResourceMirror[i].Class, &AXmString) ) XtVaSetValues((Widget) w, ResourceMirror[i].Name, @@ -2642,7 +2661,8 @@ static void InitMirrorResources(XmComboB break; case RXmStringTable: if ( FetchXmStringTableResource((Widget) w, - FullName, FullClass, + FullName, sizeof(FullName), + FullClass, sizeof(FullClass), ResourceMirror[i].Name, ResourceMirror[i].Class, &AStringTable, &TableSize) ) { XtVaSetValues((Widget) w, @@ -2652,7 +2672,8 @@ static void InitMirrorResources(XmComboB break; case RKeySym: if ( FetchKeySymResource((Widget) w, - FullName, FullClass, + FullName, sizeof(FullName), + FullClass, sizeof(FullClass), ResourceMirror[i].Name, ResourceMirror[i].Class, &AKeySym) ) XtVaSetValues((Widget) w, ResourceMirror[i].Name, @@ -2660,7 +2681,8 @@ static void InitMirrorResources(XmComboB break; case RString: if ( FetchStringResource((Widget) w, - FullName, FullClass, + FullName, sizeof(FullName), + FullClass, sizeof(FullClass), ResourceMirror[i].Name, ResourceMirror[i].Class, &AString) ) XtVaSetValues((Widget) w, ResourceMirror[i].Name, @@ -2668,7 +2690,8 @@ static void InitMirrorResources(XmComboB break; case RPixmap: if ( FetchPixmapResource((Widget) w, - FullName, FullClass, + FullName, sizeof(FullName), + FullClass, sizeof(FullClass), ResourceMirror[i].Name, ResourceMirror[i].Class, &APixmap) ) { XtVaSetValues((Widget) w, ResourceMirror[i].Name, @@ -2681,7 +2704,8 @@ static void InitMirrorResources(XmComboB break; case RXmFontList: if ( FetchXmFontListResource((Widget) w, - FullName, FullClass, + FullName, sizeof(FullName), + FullClass, sizeof(FullClass), ResourceMirror[i].Name, ResourceMirror[i].Class, &AFontList) ) XtVaSetValues((Widget) w, ResourceMirror[i].Name,