This should fix the recent cvs breakage - PR bin/22276
Use asprintf() instead of malloc(), sprintf() pairs. Now that CVSADM_xxx is getCVSdir("xxx"), sizeof CVSADM_xxx isn't quite right! (Who knows why gcc doesn't error 'sizeof function()' though?) Note this compiles, but isn't tested (yet).
This commit is contained in:
parent
faae8634e1
commit
d1fbc02d92
9
gnu/dist/cvs/src/client.c
vendored
9
gnu/dist/cvs/src/client.c
vendored
@ -2615,8 +2615,7 @@ do_deferred_progs ()
|
||||
}
|
||||
for (p = checkin_progs; p != NULL; )
|
||||
{
|
||||
fname = xmalloc (strlen (p->dir) + sizeof CVSADM_CIPROG + 10);
|
||||
sprintf (fname, "%s/%s", p->dir, CVSADM_CIPROG);
|
||||
asprintf (&fname, "%s/%s", p->dir, CVSADM_CIPROG);
|
||||
f = open_file (fname, "w");
|
||||
if (fprintf (f, "%s\n", p->name) < 0)
|
||||
error (1, errno, "writing %s", fname);
|
||||
@ -2632,8 +2631,7 @@ do_deferred_progs ()
|
||||
checkin_progs = NULL;
|
||||
for (p = update_progs; p != NULL; )
|
||||
{
|
||||
fname = xmalloc (strlen (p->dir) + sizeof CVSADM_UPROG + 10);
|
||||
sprintf (fname, "%s/%s", p->dir, CVSADM_UPROG);
|
||||
asprintf (&fname, "%s/%s", p->dir, CVSADM_UPROG);
|
||||
f = open_file (fname, "w");
|
||||
if (fprintf (f, "%s\n", p->name) < 0)
|
||||
error (1, errno, "writing %s", fname);
|
||||
@ -5373,8 +5371,7 @@ send_dirent_proc (callerdat, dir, repository, update_dir, entries)
|
||||
* This case will happen when checking out a module defined as
|
||||
* ``-a .''.
|
||||
*/
|
||||
cvsadm_name = xmalloc (strlen (dir) + sizeof (CVSADM) + 10);
|
||||
sprintf (cvsadm_name, "%s/%s", dir, CVSADM);
|
||||
asprintf (&cvsadm_name, "%s/%s", dir, CVSADM);
|
||||
dir_exists = isdir (cvsadm_name);
|
||||
free (cvsadm_name);
|
||||
|
||||
|
13
gnu/dist/cvs/src/commit.c
vendored
13
gnu/dist/cvs/src/commit.c
vendored
@ -1796,9 +1796,8 @@ finaladd (finfo, rev, tag, options)
|
||||
ret = Checkin ('A', finfo, rcs, rev, tag, options, saved_message);
|
||||
if (ret == 0)
|
||||
{
|
||||
char *tmp = xmalloc (strlen (finfo->file) + sizeof (CVSADM)
|
||||
+ sizeof (CVSEXT_LOG) + 10);
|
||||
(void) sprintf (tmp, "%s/%s%s", CVSADM, finfo->file, CVSEXT_LOG);
|
||||
char *tmp;
|
||||
(void) asprintf (&tmp, "%s/%s%s", CVSADM, finfo->file, CVSEXT_LOG);
|
||||
if (unlink_file (tmp) < 0
|
||||
&& !existence_error (errno))
|
||||
error (0, errno, "cannot remove %s", tmp);
|
||||
@ -2005,9 +2004,7 @@ checkaddfile (file, repository, tag, options, rcsnode)
|
||||
desc = NULL;
|
||||
descalloc = 0;
|
||||
desclen = 0;
|
||||
fname = xmalloc (strlen (file) + sizeof (CVSADM)
|
||||
+ sizeof (CVSEXT_LOG) + 10);
|
||||
(void) sprintf (fname, "%s/%s%s", CVSADM, file, CVSEXT_LOG);
|
||||
(void) asprintf (&fname, "%s/%s%s", CVSADM, file, CVSEXT_LOG);
|
||||
/* If the file does not exist, no big deal. In particular, the
|
||||
server does not (yet at least) create CVSEXT_LOG files. */
|
||||
if (isfile (fname))
|
||||
@ -2069,9 +2066,7 @@ checkaddfile (file, repository, tag, options, rcsnode)
|
||||
FILE *fp;
|
||||
|
||||
/* move the new file out of the way. */
|
||||
fname = xmalloc (strlen (file) + sizeof (CVSADM)
|
||||
+ sizeof (CVSPREFIX) + 10);
|
||||
(void) sprintf (fname, "%s/%s%s", CVSADM, CVSPREFIX, file);
|
||||
(void) asprintf (&fname, "%s/%s%s", CVSADM, CVSPREFIX, file);
|
||||
rename_file (file, fname);
|
||||
|
||||
/* Create empty FILE. Can't use copy_file with a DEVNULL
|
||||
|
6
gnu/dist/cvs/src/diff.c
vendored
6
gnu/dist/cvs/src/diff.c
vendored
@ -650,11 +650,7 @@ diff_fileproc (callerdat, finfo)
|
||||
if (tocvsPath)
|
||||
{
|
||||
/* Backup the current version of the file to CVS/,,filename */
|
||||
fname = xmalloc (strlen (finfo->file)
|
||||
+ sizeof CVSADM
|
||||
+ sizeof CVSPREFIX
|
||||
+ 10);
|
||||
sprintf(fname,"%s/%s%s",CVSADM, CVSPREFIX, finfo->file);
|
||||
asprintf(&fname,"%s/%s%s",CVSADM, CVSPREFIX, finfo->file);
|
||||
if (unlink_file_dir (fname) < 0)
|
||||
if (! existence_error (errno))
|
||||
error (1, errno, "cannot remove %s", fname);
|
||||
|
10
gnu/dist/cvs/src/edit.c
vendored
10
gnu/dist/cvs/src/edit.c
vendored
@ -334,10 +334,7 @@ edit_fileproc (callerdat, finfo)
|
||||
trying to create the output file fails. But copy_file isn't
|
||||
set up to facilitate that. */
|
||||
mkdir_if_needed (CVSADM_BASE);
|
||||
basefilename = xmalloc (10 + sizeof CVSADM_BASE + strlen (finfo->file));
|
||||
strcpy (basefilename, CVSADM_BASE);
|
||||
strcat (basefilename, "/");
|
||||
strcat (basefilename, finfo->file);
|
||||
asprintf(&basefilename, "%s/%s", CVSADM_BASE, finfo->file);
|
||||
copy_file (finfo->file, basefilename);
|
||||
free (basefilename);
|
||||
|
||||
@ -466,10 +463,7 @@ unedit_fileproc (callerdat, finfo)
|
||||
if (noexec)
|
||||
return 0;
|
||||
|
||||
basefilename = xmalloc (10 + sizeof CVSADM_BASE + strlen (finfo->file));
|
||||
strcpy (basefilename, CVSADM_BASE);
|
||||
strcat (basefilename, "/");
|
||||
strcat (basefilename, finfo->file);
|
||||
asprintf(&basefilename, "%s/%s", CVSADM_BASE, finfo->file);
|
||||
if (!isfile (basefilename))
|
||||
{
|
||||
/* This file apparently was never cvs edit'd (e.g. we are uneditting
|
||||
|
34
gnu/dist/cvs/src/entries.c
vendored
34
gnu/dist/cvs/src/entries.c
vendored
@ -651,13 +651,10 @@ WriteTag (dir, tag, date, nonbranch, update_dir, repository)
|
||||
if (noexec)
|
||||
return;
|
||||
|
||||
tmp = xmalloc ((dir ? strlen (dir) : 0)
|
||||
+ sizeof (CVSADM_TAG)
|
||||
+ 10);
|
||||
if (dir == NULL)
|
||||
(void) strcpy (tmp, CVSADM_TAG);
|
||||
tmp = xstrdup(CVSADM_TAG);
|
||||
else
|
||||
(void) sprintf (tmp, "%s/%s", dir, CVSADM_TAG);
|
||||
(void) asprintf (&tmp, "%s/%s", dir, CVSADM_TAG);
|
||||
|
||||
if (tag || date)
|
||||
{
|
||||
@ -851,12 +848,7 @@ subdir_record (cmd, parent, dir)
|
||||
if (parent == NULL)
|
||||
entfilename = (char *)CVSADM_ENTLOG;
|
||||
else
|
||||
{
|
||||
entfilename = xmalloc (strlen (parent)
|
||||
+ sizeof CVSADM_ENTLOG
|
||||
+ 10);
|
||||
sprintf (entfilename, "%s/%s", parent, CVSADM_ENTLOG);
|
||||
}
|
||||
asprintf (&entfilename, "%s/%s", parent, CVSADM_ENTLOG);
|
||||
|
||||
entfile = CVS_FOPEN (entfilename, "a");
|
||||
if (entfile == NULL)
|
||||
@ -1023,23 +1015,15 @@ base_walk (code, finfo, rev)
|
||||
computation probably should be broken out into a separate function,
|
||||
as recurse.c does it too and places like Entries_Open should be
|
||||
doing it. */
|
||||
baserev_fullname = xmalloc (sizeof (CVSADM_BASEREV)
|
||||
+ strlen (finfo->update_dir)
|
||||
+ 2);
|
||||
baserev_fullname[0] = '\0';
|
||||
baserevtmp_fullname = xmalloc (sizeof (CVSADM_BASEREVTMP)
|
||||
+ strlen (finfo->update_dir)
|
||||
+ 2);
|
||||
baserevtmp_fullname[0] = '\0';
|
||||
if (finfo->update_dir[0] != '\0')
|
||||
{
|
||||
strcat (baserev_fullname, finfo->update_dir);
|
||||
strcat (baserev_fullname, "/");
|
||||
strcat (baserevtmp_fullname, finfo->update_dir);
|
||||
strcat (baserevtmp_fullname, "/");
|
||||
asprintf(&baserev_fullname, "%s/%s", finfo->update_dir, CVSADM_BASEREV);
|
||||
asprintf(&baserevtmp_fullname, "%s/%s",
|
||||
finfo->update_dir, CVSADM_BASEREVTMP);
|
||||
} else {
|
||||
baserev_fullname = xstrdup(CVSADM_BASEREV);
|
||||
baserevtmp_fullname = xstrdup(CVSADM_BASEREVTMP);
|
||||
}
|
||||
strcat (baserev_fullname, CVSADM_BASEREV);
|
||||
strcat (baserevtmp_fullname, CVSADM_BASEREVTMP);
|
||||
|
||||
fp = CVS_FOPEN (CVSADM_BASEREV, "r");
|
||||
if (fp == NULL)
|
||||
|
6
gnu/dist/cvs/src/find_names.c
vendored
6
gnu/dist/cvs/src/find_names.c
vendored
@ -363,7 +363,7 @@ find_dirs (dir, list, checkadm, entries)
|
||||
expand_string (&tmp,
|
||||
&tmp_size,
|
||||
strlen (dir) + strlen (dp->d_name) + 10);
|
||||
sprintf (tmp, "%s/%s", dir, dp->d_name);
|
||||
snprintf (tmp, tmp_size, "%s/%s", dir, dp->d_name);
|
||||
if (!isdir (tmp))
|
||||
goto do_it_again;
|
||||
|
||||
@ -394,8 +394,8 @@ find_dirs (dir, list, checkadm, entries)
|
||||
expand_string (&tmp,
|
||||
&tmp_size,
|
||||
(strlen (dir) + strlen (dp->d_name)
|
||||
+ sizeof (CVSADM) + 10));
|
||||
(void) sprintf (tmp, "%s/%s/%s", dir, dp->d_name, CVSADM);
|
||||
+ strlen (CVSADM) + 10));
|
||||
(void) snprintf (tmp, tmp_size, "%s/%s/%s", dir, dp->d_name, CVSADM);
|
||||
if (!isdir (tmp))
|
||||
goto do_it_again;
|
||||
}
|
||||
|
6
gnu/dist/cvs/src/ignore.c
vendored
6
gnu/dist/cvs/src/ignore.c
vendored
@ -435,8 +435,7 @@ ignore_files (ilist, entries, update_dir, proc)
|
||||
this directory if there is a CVS subdirectory.
|
||||
This will normally be the case, but the user may
|
||||
have messed up the working directory somehow. */
|
||||
p = xmalloc (strlen (file) + sizeof CVSADM + 10);
|
||||
sprintf (p, "%s/%s", file, CVSADM);
|
||||
asprintf (&p, "%s/%s", file, CVSADM);
|
||||
dir = isdir (p);
|
||||
free (p);
|
||||
if (dir)
|
||||
@ -469,8 +468,7 @@ ignore_files (ilist, entries, update_dir, proc)
|
||||
{
|
||||
char *temp;
|
||||
|
||||
temp = xmalloc (strlen (file) + sizeof (CVSADM) + 10);
|
||||
(void) sprintf (temp, "%s/%s", file, CVSADM);
|
||||
(void) asprintf (&temp, "%s/%s", file, CVSADM);
|
||||
if (isdir (temp))
|
||||
{
|
||||
free (temp);
|
||||
|
4
gnu/dist/cvs/src/recurse.c
vendored
4
gnu/dist/cvs/src/recurse.c
vendored
@ -956,8 +956,8 @@ but CVS uses %s for its own purposes; skipping %s directory",
|
||||
char *cvsadmdir;
|
||||
|
||||
cvsadmdir = xmalloc (strlen (dir)
|
||||
+ sizeof (CVSADM_REP)
|
||||
+ sizeof (CVSADM_ENT)
|
||||
+ strlen (CVSADM_REP)
|
||||
+ strlen (CVSADM_ENT)
|
||||
+ 80);
|
||||
|
||||
strcpy (cvsadmdir, dir);
|
||||
|
6
gnu/dist/cvs/src/remove.c
vendored
6
gnu/dist/cvs/src/remove.c
vendored
@ -197,11 +197,7 @@ remove_fileproc (callerdat, finfo)
|
||||
* remove the ,t file for it and scratch it from the
|
||||
* entries file. */
|
||||
Scratch_Entry (finfo->entries, finfo->file);
|
||||
fname = xmalloc (strlen (finfo->file)
|
||||
+ sizeof (CVSADM)
|
||||
+ sizeof (CVSEXT_LOG)
|
||||
+ 10);
|
||||
(void) sprintf (fname, "%s/%s%s", CVSADM, finfo->file, CVSEXT_LOG);
|
||||
(void) asprintf (&fname, "%s/%s%s", CVSADM, finfo->file, CVSEXT_LOG);
|
||||
if (unlink_file (fname) < 0
|
||||
&& !existence_error (errno))
|
||||
error (0, errno, "cannot remove %s", CVSEXT_LOG);
|
||||
|
10
gnu/dist/cvs/src/repos.c
vendored
10
gnu/dist/cvs/src/repos.c
vendored
@ -37,10 +37,7 @@ Name_Repository (dir, update_dir)
|
||||
xupdate_dir = ".";
|
||||
|
||||
if (dir != NULL)
|
||||
{
|
||||
tmp = xmalloc (strlen (dir) + sizeof (CVSADM_REP) + 10);
|
||||
(void) sprintf (tmp, "%s/%s", dir, CVSADM_REP);
|
||||
}
|
||||
(void) asprintf (&tmp, "%s/%s", dir, CVSADM_REP);
|
||||
else
|
||||
tmp = xstrdup (CVSADM_REP);
|
||||
|
||||
@ -56,10 +53,7 @@ Name_Repository (dir, update_dir)
|
||||
char *cvsadm;
|
||||
|
||||
if (dir != NULL)
|
||||
{
|
||||
cvsadm = xmalloc (strlen (dir) + sizeof (CVSADM) + 10);
|
||||
(void) sprintf (cvsadm, "%s/%s", dir, CVSADM);
|
||||
}
|
||||
(void) asprintf (&cvsadm, "%s/%s", dir, CVSADM);
|
||||
else
|
||||
cvsadm = xstrdup (CVSADM);
|
||||
|
||||
|
11
gnu/dist/cvs/src/root.c
vendored
11
gnu/dist/cvs/src/root.c
vendored
@ -42,10 +42,8 @@ Name_Root (dir, update_dir)
|
||||
|
||||
if (dir != NULL)
|
||||
{
|
||||
cvsadm = xmalloc (strlen (dir) + sizeof (CVSADM) + 10);
|
||||
(void) sprintf (cvsadm, "%s/%s", dir, CVSADM);
|
||||
tmp = xmalloc (strlen (dir) + sizeof (CVSADM_ROOT) + 10);
|
||||
(void) sprintf (tmp, "%s/%s", dir, CVSADM_ROOT);
|
||||
(void) asprintf (&cvsadm, "%s/%s", dir, CVSADM);
|
||||
(void) asprintf (&tmp, "%s/%s", dir, CVSADM_ROOT);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -152,10 +150,7 @@ Create_Root (dir, rootdir)
|
||||
if (rootdir != NULL)
|
||||
{
|
||||
if (dir != NULL)
|
||||
{
|
||||
tmp = xmalloc (strlen (dir) + sizeof (CVSADM_ROOT) + 10);
|
||||
(void) sprintf (tmp, "%s/%s", dir, CVSADM_ROOT);
|
||||
}
|
||||
(void) asprintf (&tmp, "%s/%s", dir, CVSADM_ROOT);
|
||||
else
|
||||
tmp = xstrdup (CVSADM_ROOT);
|
||||
|
||||
|
27
gnu/dist/cvs/src/update.c
vendored
27
gnu/dist/cvs/src/update.c
vendored
@ -1010,8 +1010,7 @@ update_dirent_proc (callerdat, dir, repository, update_dir, entries)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
tmp = xmalloc (strlen (dir) + sizeof (CVSADM_ENTSTAT) + 10);
|
||||
(void) sprintf (tmp, "%s/%s", dir, CVSADM_ENTSTAT);
|
||||
(void) asprintf (&tmp, "%s/%s", dir, CVSADM_ENTSTAT);
|
||||
if (unlink_file (tmp) < 0 && ! existence_error (errno))
|
||||
error (1, errno, "cannot remove file %s", tmp);
|
||||
#ifdef SERVER_SUPPORT
|
||||
@ -1305,11 +1304,7 @@ checkout_file (finfo, vers_ts, adding, merging, update_server)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
backup = xmalloc (strlen (finfo->file)
|
||||
+ sizeof (CVSADM)
|
||||
+ sizeof (CVSPREFIX)
|
||||
+ 10);
|
||||
(void) sprintf (backup, "%s/%s%s", CVSADM, CVSPREFIX, finfo->file);
|
||||
(void) asprintf (&backup, "%s/%s%s", CVSADM, CVSPREFIX, finfo->file);
|
||||
if (isfile (finfo->file))
|
||||
rename_file (finfo->file, backup);
|
||||
else
|
||||
@ -1670,11 +1665,7 @@ patch_file (finfo, vers_ts, docheckout, file_info, checksum)
|
||||
return 0;
|
||||
}
|
||||
|
||||
backup = xmalloc (strlen (finfo->file)
|
||||
+ sizeof (CVSADM)
|
||||
+ sizeof (CVSPREFIX)
|
||||
+ 10);
|
||||
(void) sprintf (backup, "%s/%s%s", CVSADM, CVSPREFIX, finfo->file);
|
||||
(void) asprintf (&backup, "%s/%s%s", CVSADM, CVSPREFIX, finfo->file);
|
||||
if (isfile (finfo->file))
|
||||
rename_file (finfo->file, backup);
|
||||
else
|
||||
@ -1684,16 +1675,8 @@ patch_file (finfo, vers_ts, docheckout, file_info, checksum)
|
||||
error (0, errno, "cannot remove %s", backup);
|
||||
}
|
||||
|
||||
file1 = xmalloc (strlen (finfo->file)
|
||||
+ sizeof (CVSADM)
|
||||
+ sizeof (CVSPREFIX)
|
||||
+ 10);
|
||||
(void) sprintf (file1, "%s/%s%s-1", CVSADM, CVSPREFIX, finfo->file);
|
||||
file2 = xmalloc (strlen (finfo->file)
|
||||
+ sizeof (CVSADM)
|
||||
+ sizeof (CVSPREFIX)
|
||||
+ 10);
|
||||
(void) sprintf (file2, "%s/%s%s-2", CVSADM, CVSPREFIX, finfo->file);
|
||||
(void) asprintf (&file1, "%s/%s%s-1", CVSADM, CVSPREFIX, finfo->file);
|
||||
(void) asprintf (&file2, "%s/%s%s-2", CVSADM, CVSPREFIX, finfo->file);
|
||||
|
||||
fail = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user