public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michael Kerrisk (man-pages)" <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Ville Ylenius <ville-xG8NWnMrmhjR7s880joybQ@public.gmane.org>
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: Typo in example code of process_vm_readv
Date: Sun, 17 Aug 2014 10:53:06 -0500	[thread overview]
Message-ID: <53F0CFE2.9040309@gmail.com> (raw)
In-Reply-To: <53EF41F4.2030509-xG8NWnMrmhjR7s880joybQ@public.gmane.org>

On 08/16/2014 06:35 AM, Ville Ylenius wrote:
> Hi,
> 
> there is a small typo in the example code of the man page of 
> "process_vm_readv" 
> (http://man7.org/linux/man-pages/man2/process_vm_readv.2.html):
> 
>         #include <sys/uio.h>
> 
>         int
>         main(void)
>         {
>             struct iovec local[2];
>             struct iovec remote[1];
>             char buf1[10];
>             char buf2[10];
>             ssize_t nread;
>             pid_t pid = 10;             /* PID of remote process */
> 
>             local[0].iov_base = buf1;
>             local[0].iov_len = 10;
>             local[1].iov_base = buf2;
>             local[1].iov_len = 10;
>             remote[0].iov_base = (void *) 0x10000;
>             remote[1].iov_len = 20;                     /**** <---- TYPO: 1 --> 0 ****/
> 
>             nread = process_vm_readv(pid, local, 2, remote, 1, 0);
>             if (nread != 20)
>                 return 1;
>             else
>                 return 0;
>         }
> 
> 
> There is no two objects in "remote"-array so program corrupts other 
> variables memory.
> 
> Please change
> 
> remote[1].iov_len = 20;
> 
> to
> 
> remote[0].iov_len = 20;

Thanks, Ville. Fixed now.

Cheers,

Michael



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2014-08-17 15:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-16 11:35 Typo in example code of process_vm_readv Ville Ylenius
     [not found] ` <53EF41F4.2030509-xG8NWnMrmhjR7s880joybQ@public.gmane.org>
2014-08-17 15:53   ` Michael Kerrisk (man-pages) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53F0CFE2.9040309@gmail.com \
    --to=mtk.manpages-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ville-xG8NWnMrmhjR7s880joybQ@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox