Re: [patch] kernel events layer

Dan Aloni
2004-07-23T21:32:13Z

On Fri, Jul 23, 2004 at 01:41:57PM -0400, Robert Love wrote:

> +void send_kmessage(int type, const char *object, const char *signal,
> + const char *fmt, ...)
> +{
> + char *buffer;
> + int len;
> + int ret;
> +
> + if (!object)
> + return;
> +
> + if (!signal)
> + return;
> +
> + if (strlen(object) > PAGE_SIZE)
> + return;
> +
> + buffer = (char *) get_zeroed_page(GFP_ATOMIC);
> + if (!buffer)
> + return;
> +
> + len = sprintf(buffer, "From: %s\n", object);
> + len += sprintf(&buffer[len], "Signal: %s\n", signal);

IMHO you either should not assume anything about the length of the object
string, _or_ do the complete safe string assembly e.g:

len += snprintf(buffer, PAGE_SIZE, "From: %s\nSignal: %s\n",
object, signal);

--
Dan Aloni
da-x@colinux.org