[packages/cvs-fast-export] - added tsan,asan,ubsan patches (fix issues detected by gcc sanitizers)

qboosh qboosh at pld-linux.org
Sat Dec 16 20:09:43 CET 2023


commit 0b0bfc9af43a1c8ba3d9996684c636c88035315f
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Sat Dec 16 19:51:52 2023 +0100

    - added tsan,asan,ubsan patches (fix issues detected by gcc sanitizers)

 cvs-fast-export-asan.patch  |  20 ++++++++
 cvs-fast-export-tsan.patch  | 120 ++++++++++++++++++++++++++++++++++++++++++++
 cvs-fast-export-ubsan.patch |  39 ++++++++++++++
 cvs-fast-export.spec        |   6 +++
 4 files changed, 185 insertions(+)
---
diff --git a/cvs-fast-export.spec b/cvs-fast-export.spec
index f7745f9..c49c67c 100644
--- a/cvs-fast-export.spec
+++ b/cvs-fast-export.spec
@@ -12,6 +12,9 @@ Group:		Development/Version Control
 Source0:	http://www.catb.org/~esr/cvs-fast-export/%{name}-%{version}.tar.gz
 # Source0-md5:	8ed2dac4c7c1763d8351650d0bb2630c
 Patch0:		hack-disable-cvsignore.patch
+Patch1:		%{name}-tsan.patch
+Patch2:		%{name}-asan.patch
+Patch3:		%{name}-ubsan.patch
 URL:		http://www.catb.org/~esr/cvs-fast-export/
 BuildRequires:	asciidoc
 BuildRequires:	sed >= 4.0
@@ -45,6 +48,9 @@ ze zdalnych serwerów CVS.
 %prep
 %setup -q
 %patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
 
 %{__sed} -i -e '1s,/usr/bin/env python3$,%{__python3},' cvsconvert cvsstrip
 
diff --git a/cvs-fast-export-asan.patch b/cvs-fast-export-asan.patch
new file mode 100644
index 0000000..26b4721
--- /dev/null
+++ b/cvs-fast-export-asan.patch
@@ -0,0 +1,20 @@
+--- cvs-fast-export-1.62/export.c.orig	2023-12-10 22:08:38.039921414 +0100
++++ cvs-fast-export-1.62/export.c	2023-12-11 06:17:08.424656665 +0100
+@@ -208,7 +208,7 @@ static void export_blob(node_t *node,
+ 	for (char *cp = cbuf; cp < cbuf + len; cp++)
+ 	    if (*cp == ' ')
+ 		*cp = '\n';
+-	if (strlen(cbuf) >= 2 && cbuf[0] == '!' && cbuf[1] == '\n')
++	if (strnlen(cbuf, len) >= 2 && cbuf[0] == '!' && cbuf[1] == '\n')
+ 	    extralen = 0;
+     }
+ 
+@@ -697,7 +697,7 @@ static struct commit_seq *canonicalize(g
+ #define is_branchroot_of(x, y) ((x)->head == (y)->head && (x)->isbase)
+ #define is_older_than(x, y) (((struct commit_seq *)x)->commit->date < ((struct commit_seq *)y)->commit->date)
+ 	/* back up as far as we can */
+-	while (!is_parent_of(bp-1, hp) && !is_branchroot_of(bp-1, hp) && !is_older_than(bp-1, hp))
++	while ((bp > history) && !is_parent_of(bp-1, hp) && !is_branchroot_of(bp-1, hp) && !is_older_than(bp-1, hp))
+ 	    bp--;
+ 	if (bp < hp) {
+ 	    /* shift commits up and put *hp where *bp was */
diff --git a/cvs-fast-export-tsan.patch b/cvs-fast-export-tsan.patch
new file mode 100644
index 0000000..48b831a
--- /dev/null
+++ b/cvs-fast-export-tsan.patch
@@ -0,0 +1,120 @@
+--- cvs-fast-export-1.62/atom.c.orig	2023-12-10 21:33:28.557717340 +0100
++++ cvs-fast-export-1.62/atom.c	2023-12-10 21:33:33.707747222 +0100
+@@ -99,21 +99,22 @@ atom(const char *string)
+     hash_bucket_t	*b;
+     int			len;
+ 
+-    while ((b = *head)) {
+-collision:
+-	if (b->hash == hash && !strcmp(string, b->string))
+-	    return b->string;
+-	head = &(b->next);
+-    }
+ #ifdef THREADS
+     if (threads > 1)
+ 	pthread_mutex_lock(&bucket_mutex);
+ #endif /* THREADS */
+-    if ((b = *head)) {
++    while ((b = *head)) {
++collision:
++	if (b->hash == hash && !strcmp(string, b->string)) {
+ #ifdef THREADS
+ 	if (threads > 1)
+ 	    pthread_mutex_unlock(&bucket_mutex);
+ #endif /* THREADS */
++	    return b->string;
++	}
++	head = &(b->next);
++    }
++    if ((b = *head)) {
+ 	goto collision;
+     }
+ 
+@@ -154,21 +155,22 @@ atom_cvs_number(const cvs_number n)
+     number_bucket_t **head = &number_buckets[bucket];
+     number_bucket_t *b;
+ 
+-    while ((b = *head)) {
+-    collision:
+-	if (cvs_number_equal(&b->number, &n))
+-	    return &b->number;
+-	head = &(b->next);
+-    }
+ #ifdef THREADS
+     if (threads > 1)
+ 	pthread_mutex_lock(&number_bucket_mutex);
+ #endif /* THREADS */
+-    if ((b = *head)) {
++    while ((b = *head)) {
++    collision:
++	if (cvs_number_equal(&b->number, &n)) {
+ #ifdef THREADS
+ 	if (threads > 1)
+ 	    pthread_mutex_unlock(&number_bucket_mutex);
+ #endif /* THREADS */
++	    return &b->number;
++	}
++	head = &(b->next);
++    }
++    if ((b = *head)) {
+ 	goto collision;
+     }
+ 
+--- cvs-fast-export-1.62/revcvs.c.orig	2023-05-13 19:35:07.000000000 +0200
++++ cvs-fast-export-1.62/revcvs.c	2023-12-10 21:41:28.540502302 +0100
+@@ -22,6 +22,9 @@
+ #endif
+ 
+ const master_dir *root_dir = NULL;
++#ifdef THREADS
++static pthread_mutex_t root_dir_mutex = PTHREAD_MUTEX_INITIALIZER;
++#endif
+ 
+ static const char *
+ fileop_name(const char *rectified)
+@@ -86,21 +89,22 @@ atom_dir(const char* dirname)
+     dir_bucket **head = &dir_buckets[HASH_VALUE(dirname) % DIR_BUCKETS];
+     dir_bucket *b;
+ 
+-    while ((b = *head)) {
+-    collision:
+-	if (b->dir.name == dirname)
+-	    return &(b->dir);
+-	head = &(b->next);
+-    }
+ #ifdef THREADS
+     if (threads > 1)
+ 	pthread_mutex_lock(&dir_bucket_mutex);
+ #endif /* THREADS */
+-    if ((b = *head)) {
++    while ((b = *head)) {
++    collision:
++	if (b->dir.name == dirname) {
+ #ifdef THREADS
+ 	if (threads > 1)
+ 	    pthread_mutex_unlock(&dir_bucket_mutex);
+ #endif /* THREADS */
++	    return &(b->dir);
++	}
++	head = &(b->next);
++    }
++    if ((b = *head)) {
+ 	goto collision;
+     }
+     b = xmalloc(sizeof(dir_bucket), __func__);
+@@ -800,7 +803,15 @@ cvs_master_digest(cvs_file *cvs, cvs_mas
+     cvs_branch	*cb;
+     cvs_version	*ctrunk = NULL;
+ 
++#ifdef THREADS
++    if (threads > 1)
++	pthread_mutex_lock(&root_dir_mutex);
++#endif
+     if (!root_dir) root_dir = atom_dir(atom("\0"));
++#ifdef THREADS
++    if (threads > 1)
++	pthread_mutex_unlock(&root_dir_mutex);
++#endif
+     build_rev_master(cvs, master);
+ #if CVSDEBUG
+     char buf[CVS_MAX_REV_LEN];
diff --git a/cvs-fast-export-ubsan.patch b/cvs-fast-export-ubsan.patch
new file mode 100644
index 0000000..ab61831
--- /dev/null
+++ b/cvs-fast-export-ubsan.patch
@@ -0,0 +1,39 @@
+--- cvs-fast-export-1.62/treepack.c.orig	2019-04-26 16:03:34.000000000 +0200
++++ cvs-fast-export-1.62/treepack.c	2023-12-11 20:26:03.515346763 +0100
+@@ -215,6 +215,7 @@ revdir_pack_init(void)
+     frame = frames;
+     nfiles = 0;
+     frames[0].dir = root_dir;
++    frames[0].dirs = xmalloc(0, __func__);
+     frames[0].ndirs = 0;
+     frames[0].hash = hash_init();
+ }
+@@ -257,6 +257,7 @@ revdir_pack_add(const cvs_commit *file,
+ 	    
+ 	    const master_dir *parent = frame++->dir;
+ 	    frame->dir = first_subdir(dir, parent);
++	    frame->dirs = xmalloc(0, __func__);
+ 	    frame->ndirs = 0;
+ 	    frame->hash = hash_init();
+ 	    continue;
+--- cvs-fast-export-1.62/generate.c.orig	2023-12-16 09:25:49.122347160 +0100
++++ cvs-fast-export-1.62/generate.c	2023-12-16 09:25:51.565694258 +0100
+@@ -1058,7 +1058,7 @@ static node_t *generate_setup(generator_
+ 	eb->Gfilename = gen->master_name;
+ 	eb->Gexpand = gen->expand;
+ 	eb->Gabspath = NULL;
+-	Gline(eb) = NULL; Ggap(eb) = Ggapsize(eb) = Glinemax(eb) = 0;
++	Gline(eb) = xmalloc(0, __func__); Ggap(eb) = Ggapsize(eb) = Glinemax(eb) = 0;
+     }
+ 
+     return gen->nodehash.head_node;
+--- cvs-fast-export-1.62/import.c.orig	2023-08-28 19:20:50.000000000 +0200
++++ cvs-fast-export-1.62/import.c	2023-12-16 19:32:48.695246837 +0100
+@@ -322,6 +322,7 @@ void analyze_masters(int argc, const cha
+     striplen = analyzer->striplen;
+ 
+     forest->textsize = forest->filecount = 0;
++    forest->cvsroot = false;
+     progress_begin("Reading file list...", NO_MAX);
+     for (;;)
+     {
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/cvs-fast-export.git/commitdiff/0b0bfc9af43a1c8ba3d9996684c636c88035315f



More information about the pld-cvs-commit mailing list