Re: [PATCH] init - fix building bug and potential buffer overflow

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Geert Uytterhoeven
Date: Thursday, May 15, 2008 - 12:47 pm

On Thu, 15 May 2008, Cyrill Gorcunov wrote:

gcc turns the strncat() into an implicit call to strlen() and some form
of expanded memcpy(). E.g.


	if (preempt_count() != count) {
		strncat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
		preempt_count() = count;
	}

becomes

        cmp.l 884(%a2),%d6      | <variable>.thread.info.preempt_count, count
        jeq .L61        |
        move.l %d7,-(%sp)       | tmp76,
        jbsr strlen     |
        addq.l #4,%sp   |,
        move.l %d7,%a0  | tmp76, tmp80
        add.l %d0,%a0   |, tmp80
        move.l #1886545253,(%a0)+       |,
        move.l #1836086377,(%a0)+       |,
        move.l #1869488233,(%a0)+       |,
        move.l #1835164012,(%a0)+       |,
        move.l #1634624357,(%a0)+       |,
        move.w #8192,(%a0)      |,* D.28541
        move.l %d6,884(%a2)     | count, <variable>.thread.info.preempt_count
.L61:

All other explicit calls to strlen() are inlined, as per
include/asm-m68k/string.h.


Actually it build and runs fine after s/strncat/strlcat/...

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] init - fix building bug and potential buffer o ..., Geert Uytterhoeven, (Thu May 15, 12:47 pm)
[PATCH] Add a void * alternative to print_fn_descriptor_sy ..., Abhijit Menon-Sen, (Thu May 15, 4:41 pm)
Re: [PATCH] init - fix building bug and potential buffer o ..., Geert Uytterhoeven, (Fri May 16, 12:00 am)