Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Clemens Ladisch <clemens@ladisch.de>
Cc: Jaroslav Kysela <perex@suse.cz>, alsa-devel@lists.sourceforge.net
Subject: Re: [PATCH] fix of the get_id fix
Date: Mon, 02 Dec 2002 12:33:44 +0100	[thread overview]
Message-ID: <s5hznroac4n.wl@alsa2.suse.de> (raw)
In-Reply-To: <Pine.HPX.4.33n.0212020949450.9290-100000@studcom.urz.uni-halle.de>

[-- Attachment #1: Type: text/plain, Size: 1592 bytes --]

At Mon, 02 Dec 2002 11:39:34 +0100 (MET),
Clemens Ladisch wrote:
> 
> Jaroslav Kysela wrote:
> > revision 1.6
> > date: 2002/11/28 13:54:34;  author: perex;  state: Exp;  lines: +3 -4
> >
> > Fixed parsiong of id where dst is NULL
> >
> > Index: initval.h
> > ===================================================================
> > RCS file: /cvsroot/alsa/alsa-kernel/include/initval.h,v
> > retrieving revision 1.5
> > retrieving revision 1.6
> > diff -u -r1.5 -r1.6
> > --- initval.h   23 Nov 2002 10:41:53 -0000      1.5
> > +++ initval.h   28 Nov 2002 13:54:34 -0000      1.6
> > @@ -156,10 +156,9 @@
> >         for (s = *str; isalpha(*s) || isdigit(*s) || *s == '_'; s++);
> >         if (s != *str) {
> >                 *dst = (char *)kmalloc(s - *str, GFP_KERNEL);
> > -               if ((d = *dst) != NULL) {
> > -                       s = *str;
> > -                       while (isalpha(*s) || isdigit(*s) || *s == '_')
> > +               s = *str; d = *dst;
> > +               while (isalpha(*s) || isdigit(*s) || *s == '_')
> > +                       if (d != NULL)
> >                                 *d++ = *s++;
> > -               }
> >         }
> >         *str = s;
> 
> I'm not sure I understand what this patch tries to fix. Revision 1.5 seems
> to work when kmalloc fails (it skips the input field and returns NULL),
> but revision 1.6 goes into an infinite loop because s isn't incremented
> when d == NULL.

i guess s should be proceeded even if kmalloc fails, i.e. skip the
word.

> 
> And IMNSHO the returned string should be zero-terminated.

yep.


Takashi

[-- Attachment #2: initval-fix.dif --]
[-- Type: application/octet-stream, Size: 701 bytes --]

Index: alsa-kernel/include/initval.h
===================================================================
--- alsa-kernel/include/initval.h	29 Nov 2002 14:35:01 -0000	1.5
+++ alsa-kernel/include/initval.h	2 Dec 2002 11:30:58 -0000
@@ -155,11 +155,13 @@
 		return 0;
 	for (s = *str; isalpha(*s) || isdigit(*s) || *s == '_'; s++);
 	if (s != *str) {
-		*dst = (char *)kmalloc(s - *str, GFP_KERNEL);
+		*dst = (char *)kmalloc(s - *str + 1, GFP_KERNEL);
 		s = *str; d = *dst;
-		while (isalpha(*s) || isdigit(*s) || *s == '_')
+		for (; isalpha(*s) || isdigit(*s) || *s == '_'; s++)
 			if (d != NULL)
-				*d++ = *s++;
+				*d++ = *s;
+		if (d != NULL)
+			*d = '\0';
 	}
 	*str = s;
 	if (*s == ',') {

      reply	other threads:[~2002-12-02 11:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-02 10:39 [PATCH] fix of the get_id fix Clemens Ladisch
2002-12-02 11:33 ` Takashi Iwai [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=s5hznroac4n.wl@alsa2.suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=clemens@ladisch.de \
    --cc=perex@suse.cz \
    /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