[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 23, 2014 at 07:09:03PM +1000, Michael Ellerman wrote:
 > In output() we sprintf() the result of find_pid_slot(). We print the pid
 > slot to the buffer with %u and have space for two digits of pid slot.
 > find_pid_slot() potentially returns PIDSLOT_NOT_FOUND (-1), which when
 > printed with %u is 4294967295 - ten digits.
 > 
 > Fix it two ways, use snprintf() - truncated output is better than a
 > buffer overflow. And allocate more space in the buffer, 32 bytes is a
 > nice round size, and gives us space for everything.

heh, this has been nagging me from time to time, but it wasn't a problem
until recently.   I'm curious why you're hitting that PIDSLOT_NOT_FOUND
case though, as it's a "should never happen" case.

Anyway, it's the right thing to do, so I pushed this out.

 > @@ -311,7 +311,7 @@ void output(unsigned char level, const char *fmt, ...)
 >  		unsigned int slot;
 >  
 >  		slot = find_pid_slot(pid);
 > -		sprintf(child_prefix, "[child%u:%u]", slot, pid);
 > +		snprintf(child_prefix, sizeof(child_prefix), "[child%u:%u]", slot, pid);
 >  		prefix = child_prefix;

might be worth it to add something later to print PIDSLOT_NOT_FOUND entries as '?'
rather than 4294967295.

thanks,

	Dave

--
To unsubscribe from this list: send the line "unsubscribe trinity" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux