Ustream read callback

Hi,
how do u read correctly from a ustream socket?
This works but writing to stdout is not what I want.

static void client_read_cb(struct ustream *s, int bytes)
{
    char *buf;
    int len;

    buf = ustream_get_read_buf(s, &len);
    fwrite(buf, len, 1, stdout);
    fflush(stdout);
    ustream_consume(s, len);
}

Why does this not work?

static void client_read_cb(struct ustream *s, int bytes)
{
    char *buf;
    int len;
    
    char tmp_buffer[100];
    memcpy(tmp_buffer, buf, len);
    printf("Received: %s\n", tmp_buffer);

    ustream_consume(s, len);
}

Hmmmm...
This works

static void client_read_cb(struct ustream *s, int bytes)
{
    size_t len;
    char buf[1024];

    len = ustream_read(s, buf, sizeof(buf));
    printf("Read %ld bytes from SSL connection: %s\n", len, buf);
}

I don't get it.