Bug 560 - please do not use strcat()
please do not use strcat()
Status: CLOSED FIXED
Product: Samba 3.0
Classification: Unclassified
Component: Build environment
3.0.0
Other Linux
: P3 normal
: none
Assigned To: Tim Potter
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-10-03 20:56 UTC by Mathieu Jobin
Modified: 2005-08-24 10:21 UTC (History)
0 users

See Also:


Attachments

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$




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 1.1.2.2
diff -u -3 -p -r1.1.2.2 tdbback.c
--- tdb/tdbback.c       2 Oct 2003 18:22:51 -0000       1.1.2.2
+++ 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");
                exit(1);
        }
-       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;
 }

mjobin:~/KDE/samba/source$
Comment 1 Gerald (Jerry) Carter 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 2005-08-24 10:21:39 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.