Fix a buffer overrun while pre-formatting the names array, perpetrated in
the prior commit. Use essentially the same sprintf() statement for both formatting and pre-formatting, and use a format string which eliminates the need for an extra temporary buffer when formatting the name. Noted by: Christoph Mallon Pointy hat to: ian Approved by: cognet (mentor)
This commit is contained in:
parent
5a47db4708
commit
922c0acd57
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=245948
@ -68,13 +68,13 @@ void (*arm_post_filter)(void *) = NULL;
|
||||
* consumers of this data.
|
||||
*/
|
||||
void
|
||||
arm_intrnames_init()
|
||||
arm_intrnames_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
memset(intrnames, ' ', NIRQ * INTRNAME_LEN);
|
||||
for (i = 0; i < NIRQ; ++i)
|
||||
intrnames[i * INTRNAME_LEN - 1] = 0;
|
||||
snprintf(&intrnames[i * INTRNAME_LEN], INTRNAME_LEN, "%-*s",
|
||||
INTRNAME_LEN - 1, "");
|
||||
}
|
||||
|
||||
void
|
||||
@ -83,7 +83,6 @@ arm_setup_irqhandler(const char *name, driver_filter_t *filt,
|
||||
{
|
||||
struct intr_event *event;
|
||||
int error;
|
||||
char namebuf[INTRNAME_LEN];
|
||||
|
||||
if (irq < 0 || irq >= NIRQ)
|
||||
return;
|
||||
@ -95,9 +94,8 @@ arm_setup_irqhandler(const char *name, driver_filter_t *filt,
|
||||
if (error)
|
||||
return;
|
||||
intr_events[irq] = event;
|
||||
snprintf(namebuf, sizeof(namebuf), "irq%d: %s", irq, name);
|
||||
sprintf(intrnames + INTRNAME_LEN * irq, "%-*s",
|
||||
INTRNAME_LEN - 1, namebuf);
|
||||
snprintf(&intrnames[irq * INTRNAME_LEN], INTRNAME_LEN, "%-*s",
|
||||
INTRNAME_LEN - 1, name);
|
||||
}
|
||||
intr_event_add_handler(event, name, filt, hand, arg,
|
||||
intr_priority(flags), flags, cookiep);
|
||||
|
Loading…
Reference in New Issue
Block a user