[lxc-devel] [PATCH 1/1] lxc-user-nic: dont risk passing EOF
Stéphane Graber
stgraber at ubuntu.com
Mon Nov 25 19:41:41 UTC 2013
On Fri, Nov 22, 2013 at 08:26:20PM -0600, Serge Hallyn wrote:
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
Acked-by: Stéphane Graber <stgraber at ubuntu.com>
> ---
> src/lxc/lxc_user_nic.c | 26 +++++++++++++-------------
> 1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/src/lxc/lxc_user_nic.c b/src/lxc/lxc_user_nic.c
> index af1e944..a4ae907 100644
> --- a/src/lxc/lxc_user_nic.c
> +++ b/src/lxc/lxc_user_nic.c
> @@ -137,16 +137,16 @@ static int get_alloted(char *me, char *intype, char *link)
> return -1;
> }
>
> -static char *get_eol(char *s)
> +static char *get_eol(char *s, char *e)
> {
> - while (*s && *s != '\n')
> + while (s<e && *s && *s != '\n')
> s++;
> return s;
> }
>
> -static char *get_eow(char *s)
> +static char *get_eow(char *s, char *e)
> {
> - while (*s && !isblank(*s) && *s != '\n')
> + while (s<e && *s && !isblank(*s) && *s != '\n')
> s++;
> return s;
> }
> @@ -155,22 +155,22 @@ static char *find_line(char *p, char *e, char *u, char *t, char *l)
> {
> char *p1, *p2, *ret;
>
> - while (p < e && (p1 = get_eol(p)) < e) {
> + while (p<e && (p1 = get_eol(p, e)) < e) {
> ret = p;
> if (*p == '#')
> goto next;
> - while (isblank(*p)) p++;
> - p2 = get_eow(p);
> + while (p<e && isblank(*p)) p++;
> + p2 = get_eow(p, e);
> if (!p2 || p2-p != strlen(u) || strncmp(p, u, strlen(u)) != 0)
> goto next;
> p = p2+1;
> - while (isblank(*p)) p++;
> - p2 = get_eow(p);
> + while (p<e && isblank(*p)) p++;
> + p2 = get_eow(p, e);
> if (!p2 || p2-p != strlen(t) || strncmp(p, t, strlen(t)) != 0)
> goto next;
> p = p2+1;
> - while (isblank(*p)) p++;
> - p2 = get_eow(p);
> + while (p<e && isblank(*p)) p++;
> + p2 = get_eow(p, e);
> if (!p2 || p2-p != strlen(l) || strncmp(p, l, strlen(l)) != 0)
> goto next;
> return ret;
> @@ -329,7 +329,7 @@ static bool cull_entries(int fd, char *me, char *t, char *br)
> }
> entry_lines = newe;
> entry_lines[n].start = p;
> - entry_lines[n].len = get_eol(p) - entry_lines[n].start;
> + entry_lines[n].len = get_eol(p, e) - entry_lines[n].start;
> entry_lines[n].keep = true;
> n++;
> if (!get_nic_from_line(p, &nic))
> @@ -362,7 +362,7 @@ static int count_entries(char *buf, off_t len, char *me, char *t, char *br)
> int count = 0;
> while ((buf = find_line(buf, e, me, t, br)) != NULL) {
> count++;
> - buf = get_eol(buf)+1;
> + buf = get_eol(buf, e)+1;
> if (buf >= e)
> break;
> }
> --
> 1.8.4.3
>
>
> ------------------------------------------------------------------------------
> Shape the Mobile Experience: Free Subscription
> Software experts and developers: Be at the forefront of tech innovation.
> Intel(R) Software Adrenaline delivers strategic insight and game-changing
> conversations that shape the rapidly evolving mobile landscape. Sign up now.
> http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20131125/585ba1ce/attachment.pgp>
More information about the lxc-devel
mailing list