<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>3822</bug_id>
          
          <creation_ts>2004-03-12 02:09:48 +0300</creation_ts>
          <short_desc>String overflow in vfs_recycle.c</short_desc>
          <delta_ts>2009-05-10 09:32:01 +0400</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>samba</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Oleg Gints">go</reporter>
          <assigned_to name="Evgeny Sinelnikov">sin</assigned_to>
          <cc>sin</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>12228</commentid>
    <comment_count>0</comment_count>
    <who name="Oleg Gints">go</who>
    <bug_when>2004-03-12 02:09:49 +0300</bug_when>
    <thetext>Обнаружил в самбе небольшую ошибку.
Версия - samba-3.0.2a-alt1.M22 (сборка для Мастера)

Проявляется при активизации мусорной корзины с keeptree = yes:

[Disk_K]
comment = Disk for all
path = /home/samba/k
public = yes
writable = yes
create mask = 0666
directory mask = 777
vfs objects = recycle
recycle: keeptree = yes
recycle: maxsize = 200000000
recycle: exclude = *.avi, *.mp3, *.jpg, *.gif

При удалении каталогов на расшаренном ресурсе в логах
появляются ошибки (впрочем на работе это не сказывается):

  recycle: creating new dir .recycle/22
[2004/03/10 10:51:56, 0] lib/util_str.c:safe_strcat_fn(629)
  ERROR: string overflow by 1 in safe_strcat [/]

Расследование показало, что переполнение происходит при последнем прохождении
цикла for в функции recycle_create_dir при вызове
 safe_strcat(new_dir, &quot;/&quot;, len);
а len определен без учета этого лишнего &quot;/&quot;

Патчик для исправления:
diff -urN samba-3.0.release.orig/source/modules/vfs_recycle.c
samba-3.0.release/source/modules/vfs_recycle.c
--- samba-3.0.release.orig/source/modules/vfs_recycle.c	2003-10-11 21:34:20 +1000
+++ samba-3.0.release/source/modules/vfs_recycle.c	2004-03-10 14:27:08 +0900
@@ -219,7 +219,7 @@
 	ALLOC_CHECK(tmp_str, done);
 	tok_str = tmp_str;
 
-	len = strlen(dname);
+	len = strlen(dname) + 1; // 1 - for  dname+&quot;/&quot;
 	new_dir = (char *)malloc(len + 1);
 	ALLOC_CHECK(new_dir, done);
 	*new_dir = &apos;\0&apos;;





Expected Results:  
 recycle: creating new dir .recycle/22
[2004/03/10 10:51:56, 0] lib/util_str.c:safe_strcat_fn(629)
  ERROR: string overflow by 1 in safe_strcat [/]</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12242</commentid>
    <comment_count>1</comment_count>
    <who name="Alexander Bokovoy">ab</who>
    <bug_when>2004-03-12 17:57:49 +0300</bug_when>
    <thetext>Applied fix to CVS, will be in 3.0.2a-alt6</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12262</commentid>
    <comment_count>2</comment_count>
    <who name="Oleg Gints">go</who>
    <bug_when>2004-03-15 02:12:16 +0300</bug_when>
    <thetext>Хорошо</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>