ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Alexey Tourbin <at@altlinux.ru>
To: ALT Linux Team development discussions <devel@lists.altlinux.org>
Subject: Re: [devel] IA: destination buffer overflow - ppp
Date: Wed, 28 Nov 2007 13:34:38 +0300
Message-ID: <20071128103438.GP361@solemn.turbinal> (raw)
In-Reply-To: <474D4136.20706@sandy.ru>

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

On Wed, Nov 28, 2007 at 01:21:42PM +0300, Dmitriy Khanzhin wrote:
> Alexey Tourbin пишет:
> > On Wed, Nov 28, 2007 at 12:57:38PM +0300, Dmitriy Khanzhin wrote:
> > Вы что сделать-то хотите?  Чтобы gcc не выдавал warning?
> 
> Я хочу понять, как оно работает, и сделать, чтобы не было warning'а и
> что-бы работало.

Вы не рубите.  Почитайте книжку называется "Си" авторы Керниган и Ритчи.

> > Короче лучше используйте snprintf, там ошибиться сложнее что к чему.
> > 
> > Но snprintf это интерпретатор, теряется ЭФФЕККТИВНОСТЬ КОДА!!
> > 
> Патч с применением snprintf я показывал вчера
> http://lists.altlinux.org/pipermail/devel/attachments/20071127/72869196/attachment.ksh

> --- ppp-2.4.4/pppd/plugins/radius/clientid.c.orig       2007-09-29 16:38:20 +0400                                                            
> +++ ppp-2.4.4/pppd/plugins/radius/clientid.c    2007-11-27 09:08:24 +0300                                                                    
> @@ -104,18 +104,29 @@                                                                                                                        
>  UINT4 rc_map2id(char *name)                                                                                                                 
>  {                                                                                                                                           
>         struct map2id_s *p;                                                                                                                  
> -       char ttyname[PATH_MAX];                                                                                                              
> +       char *ttyname;                                                                                                                       
> +       int ttyname_len=0;                                                                                                                   
> +       char prefix_dev[6];                                                                                                                  
>                                                                                                                                              
> -       *ttyname = '\0';                                                                                                                     
> -       if (*name != '/')                                                                                                                    
> -               strcpy(ttyname, "/dev/");                                                                                                    
> -                                                                                                                                            
> -       strncat(ttyname, name, sizeof(ttyname));                                                                                             
> +       *prefix_dev = "";                                                                                                                    
> +       ttyname_len = strlen(name)+1;                                                                                                        
> +                                                                                                                                            
> +       if (*name != '/') {                                                                                                                  
> +               *prefix_dev = "/dev/";                                                                                                       

Не беритесь, не беритесь, не беритесь за то чего Вы не понимаете.

> +               ttyname_len = ttyname_len+strlen(prefix_dev);                                                                                
> +                       }                                                                                                                    
> +                                                                                                                                            
> +       ttyname = calloc(ttyname_len, sizeof(char));                                                                                         
> +       snprintf(ttyname, ttyname_len, "%s%s", prefix_dev, name);                                                                            
>                                                                                                                                              
>         for(p = map2id_list; p; p = p->next)                                                                                                 
> -               if (!strcmp(ttyname, p->name)) return p->id;                                                                                 
> +               if (!strcmp(ttyname, p->name)) {                                                                                             
> +                       free(ttyname);                                                                                                       
> +                       return p->id;                                                                                                        
> +                               }                                                                                                            
>                                                                                                                                              
>         warn("rc_map2id: can't find tty %s in map database", ttyname);                                                                       
>                                                                                                                                              
> +       free(ttyname);                                                                                                                       
>         return 0;                                                                                                                            
>  }                                                                                                                                           

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2007-11-28 10:34 UTC|newest]

Thread overview: 112+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-25 12:08 [devel] IA: destination buffer overflow Dmitry V. Levin
2007-11-25 19:55 ` Michael Shigorin
2007-11-25 21:16   ` Dmitry V. Levin
2007-11-25 23:11     ` Igor Zubkov
2007-11-26  8:55     ` Денис Смирнов
2007-11-27 15:32       ` [devel] IA: destination buffer overflow - ppp Dmitriy Khanzhin
2007-11-27 15:45         ` Dmitry V. Levin
2007-11-27 16:01           ` Damir Shayhutdinov
2007-11-28  6:56           ` Slava Semushin
2007-11-28  8:55             ` Dmitriy Khanzhin
2007-11-28  9:11               ` Alexey Tourbin
2007-11-28  9:31                 ` Dmitriy Khanzhin
2007-11-28  9:52                   ` Dmitriy Khanzhin
2007-11-28  9:32                 ` Slava Semushin
2007-11-28  9:56                   ` Alexey Tourbin
2007-11-28  9:35               ` Alexander Bokovoy
2007-11-28  9:55                 ` Alexey Tourbin
2007-11-28 10:37                   ` Epiphanov Sergei
2007-11-28 10:41                     ` Alexey Tourbin
2007-11-28 11:37                   ` Alexander Bokovoy
2007-11-28 16:35                     ` Alexey Tourbin
2007-11-28 17:34                       ` [devel] конкатенация строк Alexey Tourbin
2007-11-28 18:56                         ` Alexander Bokovoy
2007-11-28 20:33                           ` [devel] фрагментация памяти Kirill A. Shutemov
2007-11-28 20:39                             ` Alexander Bokovoy
2007-11-28 20:48                               ` Kirill A. Shutemov
2007-11-28 19:59                         ` [devel] конкатенация строк led
2007-11-29  2:04                         ` Alexey Tourbin
2007-11-28 17:56                       ` Alexey Tourbin
2007-11-28  9:57                 ` [devel] IA: destination buffer overflow - ppp Dmitriy Khanzhin
2007-11-28 10:04                   ` Alexey Tourbin
2007-11-28 10:21                     ` Dmitriy Khanzhin
2007-11-28 10:34                       ` Alexey Tourbin [this message]
2007-11-28 10:48                         ` Dmitriy Khanzhin
2007-11-28 10:15                 ` Kirill A. Shutemov
2007-11-28 13:59                   ` Grigory Batalov
2007-11-28 10:18                 ` Led
2007-11-28 11:39                   ` Alexander Bokovoy
2007-11-28 11:52                     ` Led
2007-11-28 12:44                       ` [devel] [JT] " Alexander Bokovoy
2007-12-08 12:29                         ` [devel] [JT] разработчики, майнтейнеры Michael Shigorin
2007-12-10  9:33                           ` Alexander Bokovoy
2007-12-10 16:04                             ` Michael Shigorin
2007-12-10 16:47                               ` Alexander Bokovoy
2007-12-10 19:02                                 ` [devel] [JT] updates Michael Shigorin
2007-12-11 15:41                             ` [devel] [JT] разработчики, майнтейнеры Денис Смирнов
2007-12-11 15:48                               ` [devel] [JT] разработчики , майнтейнеры Led
2007-12-11 16:26                                 ` Денис Смирнов
2007-12-11 16:29                                   ` Alexander Bokovoy
2007-12-11 16:39                                     ` Денис Смирнов
2007-12-11 16:52                                       ` Alexander Bokovoy
2007-12-11 22:31                                         ` Денис Смирнов
2007-12-12  8:41                               ` [devel] [JT] разработчики, майнтейнеры Slava Semushin
2007-12-12 13:50                                 ` Alexey I. Froloff
2007-12-13  6:16                                 ` Денис Смирнов
2007-11-28 11:33             ` [devel] IA: destination buffer overflow - ppp Dmitry V. Levin
2007-11-28 13:00               ` Damir Shayhutdinov
2007-11-28 15:50                 ` Dmitriy Khanzhin
2007-11-28 16:41                   ` Alexey Tourbin
2007-11-29  7:53                     ` Alexey Morsov
2007-11-28 20:58                 ` Dmitry V. Levin
2007-11-29  6:10                   ` Денис Смирнов
2007-11-29  6:27                     ` Andrey Rahmatullin
2007-11-29  6:41                       ` Денис Смирнов
2007-11-29  9:28                         ` Kirill A. Shutemov
2007-11-29 11:37                           ` Денис Смирнов
2007-11-29 11:51                             ` Kirill A. Shutemov
2007-11-29 12:02                               ` Денис Смирнов
2007-11-29 12:06                                 ` Slava Semushin
2007-11-29 20:36                                   ` Денис Смирнов
2007-11-29 22:27                                   ` Dmitry V. Levin
2007-11-29  6:02               ` Денис Смирнов
2007-11-29  6:08               ` Денис Смирнов
2007-11-29  6:28                 ` Хихин Руслан
2007-11-29  6:42                   ` Andrey Rahmatullin
2007-11-29  6:01           ` Денис Смирнов
2007-12-08 12:20           ` [devel] ppp *def*route patches Michael Shigorin
2007-12-08 12:34             ` Dmitry V. Levin
2007-12-08 14:30               ` Денис Смирнов
2007-11-26 10:12     ` [devel] IA: destination buffer overflow Michael Shigorin
2007-11-26 12:17       ` Dmitry V. Levin
2007-11-26 20:24         ` [devel] main vs contrib, уже в который раз! Michael Shigorin
2007-11-27  8:53           ` Slava Semushin
2007-11-27  9:00             ` Michael Shigorin
2007-11-27 10:11     ` [devel] IA: destination buffer overflow Damir Shayhutdinov
2007-11-27 14:10       ` Dmitry V. Levin
2007-11-27 14:25         ` Damir Shayhutdinov
2007-11-27 14:33           ` Dmitry V. Levin
2007-11-27 15:25             ` Damir Shayhutdinov
2007-11-26  8:25   ` Slava Semushin
2007-11-26  9:08     ` Slava Semushin
2007-11-26 10:22       ` Michael Shigorin
2007-11-26 10:28         ` Slava Semushin
2007-11-26 10:38           ` Michael Shigorin
2007-11-26 18:50             ` Andrey Rahmatullin
2007-11-27  9:51               ` Slava Semushin
2007-11-27 17:37                 ` Andrey Rahmatullin
2007-11-27  5:54           ` Vladimir V. Kamarzin
2007-11-26 10:21     ` Michael Shigorin
2007-11-26  8:51   ` Денис Смирнов
2007-11-26 10:22     ` Michael Shigorin
2007-11-26  8:59 ` Sergey Y. Afonin
2007-11-26  9:20   ` Slava Semushin
2007-11-26  9:24     ` Damir Shayhutdinov
2007-11-26 12:00 ` Alexey Morsov
2007-11-27  5:55 ` Vladimir V. Kamarzin
2007-11-27  8:02   ` Michael Shigorin
2007-11-27 14:14     ` Dmitry V. Levin
2007-11-27 14:22       ` Michael Shigorin
2007-11-28 10:34 ` Epiphanov Sergei
2007-11-28 13:51   ` Dmitry V. Levin
2007-11-29 13:09     ` Epiphanov Sergei

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=20071128103438.GP361@solemn.turbinal \
    --to=at@altlinux.ru \
    --cc=devel@lists.altlinux.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

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git