[PATCH:libXt 4/4] Convert some sprintf calls to snprintf

Alan Coopersmith alan.coopersmith at oracle.com
Tue Dec 14 10:33:15 PST 2010


walter harms wrote:
> 
> Am 14.12.2010 01:40, schrieb Alan Coopersmith:
>> Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
>> ---
>>  src/Selection.c |    3 ++-
>>  src/Shell.c     |    5 +++--
>>  2 files changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/Selection.c b/src/Selection.c
>> index 1759c02..a138c8b 100644
>> --- a/src/Selection.c
>> +++ b/src/Selection.c
>> @@ -226,7 +226,8 @@ static Atom GetSelectionProperty(
>>   propCount = sarray->propCount++;
>>   sarray->list = (SelectionProp) XtRealloc((XtPointer)sarray->list,
>>    		(unsigned)(sarray->propCount*sizeof(SelectionPropRec)));
>> - (void) sprintf(propname, "%s%d", "_XT_SELECTION_", propCount);
>> + (void) snprintf(propname, sizeof(propname), "%s%d",
>> +		 "_XT_SELECTION_", propCount);
> 
> why not snprintf(propname, sizeof(propname), "_XT_SELECTION_%d",propCount); ?

Because I didn't notice the %s pointed to a constant string.   That's easy to
fix.

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list