Bug 560 - please do not use strcat()
Summary: please do not use strcat()
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: Build environment (show other bugs)
Version: 3.0.0
Hardware: Other Linux
: P3 normal
Target Milestone: none
Assignee: Tim Potter
QA Contact:
Depends on:
Reported: 2003-10-03 20:56 UTC by Mathieu Jobin
Modified: 2005-08-24 10:21 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Mathieu Jobin 2003-10-03 20:56:25 UTC
I'm using Mandrake 9.1
$ gcc --version
gcc (GCC) 3.2.2 (Mandrake Linux 9.1 3.2.2-3mdk)

I got a strange compilation problem, I just want to communicate it with you.

I also attach the diff/patch i use to fix the problem.

mjobin:~/KDE/samba/source$ cat output_compil
tdb/tdbback.c: In function `add_suffix':
tdb/tdbback.c:60: `__ERROR__XX__NEVER_USE_STRCAT___' undeclared (first use in 
this function)
tdb/tdbback.c:60: (Each undeclared identifier is reported only once
tdb/tdbback.c:60: for each function it appears in.)
tdb/tdbback.c:60: parse error before ';' token
make: *** [tdb/tdbback.o] Error 1
Command exited with non-zero status 2
2.02user 0.09system 0:04.28elapsed 49%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (2609major+4026minor)pagefaults 0swaps

mjobin:~/KDE/samba/source$ cvs diff
? output.diff
? output_compil
Index: tdb/tdbback.c
RCS file: /cvsroot/samba/source/tdb/tdbback.c,v
retrieving revision
diff -u -3 -p -r1.1.2.2 tdbback.c
--- tdb/tdbback.c       2 Oct 2003 18:22:51 -0000
+++ tdb/tdbback.c       4 Oct 2003 03:50:39 -0000
@@ -46,6 +46,7 @@

 static int failed;

 char *add_suffix(const char *name, const char *suffix)
        char *ret;
@@ -55,8 +56,14 @@ char *add_suffix(const char *name, const
                fprintf(stderr,"Out of memory!\n");
-       strncpy(ret, name, len);
-       strncat(ret, suffix, len);
+       //strncpy(ret, name, len);
+       //strncat(ret, suffix, len);
+       //strcat not suggested by my compiler ?...
+       int i, j;
+       for (i = 0, j = 0; i < strlen(name); i++, j++)
+               ret[i] = name[i];
+       for (i = 0; i < strlen(suffix); i++, j++)
+               ret[j] = suffix[i];
        return ret;

Comment 1 Gerald (Jerry) Carter (dead mail address) 2004-03-04 08:19:19 UTC
not an issue in the previous cvs.  Someone must have fixed 
this and not marked the bug as fixed.
Comment 2 Gerald (Jerry) Carter (dead mail address) 2005-08-24 10:21:39 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.