From 04f62c7725e66229c1d0a83cf083ac3102886e34 Mon Sep 17 00:00:00 2001 From: Alexey Khromov Date: Sun, 13 Apr 2025 22:26:47 +0300 Subject: [PATCH 1/7] Fix PKGBUILD.ci for CI workflow, added manual action start --- .gitea/workflows/arch.yaml | 6 +++--- .gitea/workflows/debpkg.yaml | 4 +++- archlinux/PKGBUILD.ci | 7 +++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/arch.yaml b/.gitea/workflows/arch.yaml index c4fae03..8d6eb8a 100644 --- a/.gitea/workflows/arch.yaml +++ b/.gitea/workflows/arch.yaml @@ -3,14 +3,14 @@ run-name: Deploy to ${{ inputs.deploy_target }} by @${{ github.actor }} 🚀 on: - push - workflow_dispatch - +if: ${{ github.ref }} == 'refs/head/master' jobs: build-arch: runs-on: arch-latest - if: ${{ github.ref }} == 'refs/head/master' + branches: - 'master' - - 'zx' + steps: - name: Checking environment continue-on-error: true diff --git a/.gitea/workflows/debpkg.yaml b/.gitea/workflows/debpkg.yaml index e85f7d7..72bd633 100644 --- a/.gitea/workflows/debpkg.yaml +++ b/.gitea/workflows/debpkg.yaml @@ -1,6 +1,8 @@ name: Debian build run-name: Deploy to ${{ inputs.deploy_target }} by @${{ github.actor }} 🚀 -on: [push] +on: + - push + - workflow_dispatch jobs: build-ubuntu: runs-on: ubuntu-latest diff --git a/archlinux/PKGBUILD.ci b/archlinux/PKGBUILD.ci index 44e120f..f26bb27 100644 --- a/archlinux/PKGBUILD.ci +++ b/archlinux/PKGBUILD.ci @@ -6,7 +6,7 @@ arch=('i686' 'x86_64' 'aarch64') url="https://prj.zxalexis.ru/gitea/zx/bforce/" license=('GPL2') source=( - "${pkgname}::git+https://prj.zxalexis.ru/gitea/${GITHUB_REF_NAME}/bforce.git" + "${pkgname}::git+https://prj.zxalexis.ru/gitea/zx/bforce.git" ) makedepends=('git' 'gcc' 'make' 'glibc') provides=('bforce') @@ -25,7 +25,10 @@ prepare() { pkgver() { cd "$pkgname" - printf "r%s.%s.%s" "$(git rev-list --count ${GITHUB_SHA})" "$(git rev-parse --short ${GITHUB_SHA})" "${GITHUB_REF_NAME}" + if [ "${GITHUB_REF_TYPE}" = "tags" ]; then + printf "r%s.%s.%s" "$(git rev-list --count ${GITHUB_SHA})" "$(git rev-parse --short ${GITHUB_SHA})" "${GITHUB_REF_NAME}" + else + printf "v%s" "${GITHUB_REF_NAME}" } package() { From 416795159fbca678af47135511c86b73690ea01e Mon Sep 17 00:00:00 2001 From: Alexey Khromov Date: Sun, 13 Apr 2025 22:30:27 +0300 Subject: [PATCH 2/7] Fix PKGBUILD.ci - if-fi --- archlinux/PKGBUILD.ci | 1 + 1 file changed, 1 insertion(+) diff --git a/archlinux/PKGBUILD.ci b/archlinux/PKGBUILD.ci index f26bb27..ce44e5f 100644 --- a/archlinux/PKGBUILD.ci +++ b/archlinux/PKGBUILD.ci @@ -29,6 +29,7 @@ pkgver() { printf "r%s.%s.%s" "$(git rev-list --count ${GITHUB_SHA})" "$(git rev-parse --short ${GITHUB_SHA})" "${GITHUB_REF_NAME}" else printf "v%s" "${GITHUB_REF_NAME}" + fi } package() { From 52b3b230b9c9f7cb12c130fe82f2e7f89fdaf43f Mon Sep 17 00:00:00 2001 From: Alexey Khromov Date: Sun, 13 Apr 2025 22:44:38 +0300 Subject: [PATCH 3/7] Fix PKGBUILD.ci - reverse naming, artifact collection --- .gitea/workflows/arch.yaml | 2 +- archlinux/PKGBUILD.ci | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/arch.yaml b/.gitea/workflows/arch.yaml index 8d6eb8a..5fdfd66 100644 --- a/.gitea/workflows/arch.yaml +++ b/.gitea/workflows/arch.yaml @@ -34,7 +34,7 @@ jobs: run: | echo "BFORCE_VER=$(cat /builder/src/bforce/source/.version)-$(date +%Y%M%d)" >> $GITHUB_ENV - name: Retrieving artifact files - run: mkdir bforce && cp /builder/bforce-r*.pkg.tar.zst bforce + run: mkdir bforce && cp /builder/bforce-*.pkg.tar.zst bforce - name: Try to upload artifacts uses: actions/upload-artifact@v3 with: diff --git a/archlinux/PKGBUILD.ci b/archlinux/PKGBUILD.ci index ce44e5f..0510dc4 100644 --- a/archlinux/PKGBUILD.ci +++ b/archlinux/PKGBUILD.ci @@ -26,9 +26,9 @@ prepare() { pkgver() { cd "$pkgname" if [ "${GITHUB_REF_TYPE}" = "tags" ]; then - printf "r%s.%s.%s" "$(git rev-list --count ${GITHUB_SHA})" "$(git rev-parse --short ${GITHUB_SHA})" "${GITHUB_REF_NAME}" - else printf "v%s" "${GITHUB_REF_NAME}" + else + printf "r%s.%s.%s" "$(git rev-list --count ${GITHUB_SHA})" "$(git rev-parse --short ${GITHUB_SHA})" "${GITHUB_REF_NAME}" fi } From 7f7e420b132b8732d53230a0d455ed4aa163817d Mon Sep 17 00:00:00 2001 From: Alexey Khromov Date: Sun, 13 Apr 2025 23:01:37 +0300 Subject: [PATCH 4/7] Fix arch workflow to download only master version of PKGBUILD.ci --- .gitea/workflows/arch.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/arch.yaml b/.gitea/workflows/arch.yaml index 5fdfd66..108bc79 100644 --- a/.gitea/workflows/arch.yaml +++ b/.gitea/workflows/arch.yaml @@ -24,8 +24,8 @@ jobs: run: useradd -d /builder -g users -m builder - name: Downloading PKGBUILD run: | - su - builder -c "curl -O http://zxprj:3001/zx/bforce/raw/branch/${GITHUB_REF_NAME}/archlinux/bforce.install" - su - builder -c "curl -o PKGBUILD http://zxprj:3001/zx/bforce/raw/branch/${GITHUB_REF_NAME}/archlinux/PKGBUILD.ci" + su - builder -c "curl -O http://zxprj:3001/zx/bforce/raw/branch/master/archlinux/bforce.install" + su - builder -c "curl -o PKGBUILD http://zxprj:3001/zx/bforce/raw/branch/master/archlinux/PKGBUILD.ci" - name: Building archlinux package run: | su -w GITHUB_SHA,GITHUB_REF_NAME,GITHUB_REF_TYPE - builder -c makepkg From 4d48c2abe9cc5583cf7b2fcdaa5ce29f953f731d Mon Sep 17 00:00:00 2001 From: Alexey Khromov Date: Mon, 14 Apr 2025 21:26:17 +0300 Subject: [PATCH 5/7] fx version.h for years --- README.md | 6 +++++- source/include/version.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8a774c9..4d94a81 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![zx branch](https://prj.zxalexis.ru/gitea/zx/bforce/actions/workflows/arch.yaml/badge.svg?branch=zx) +![master branch](https://prj.zxalexis.ru/gitea/zx/bforce/actions/workflows/arch.yaml/badge.svg?branch=master) BinkleyForce FTN mailer ----------------------- @@ -45,6 +45,10 @@ New Versions https://prj.zxalexis.ru/gitea/zx/bforce +SAST Tools +---------- +[PVS-Studio](https://pvs-studio.com/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source) - static analyzer for C, C++, C#, and Java code. + Older Sources ------------- https://github.com/zotrix/binkleyforce/ diff --git a/source/include/version.h b/source/include/version.h index 3f679f3..24399e0 100644 --- a/source/include/version.h +++ b/source/include/version.h @@ -21,7 +21,7 @@ #define BF_VERSION RELEASE_VERSION #define BF_CDATE __DATE__ __TIME__ #define BF_REG "free software" -#define BF_COPYRIGHT "(c) 1997-2000 by Alexander Belkin" +#define BF_COPYRIGHT "(c) 1997-2000 by Alexander Belkin, 2004-2025 fidonet members" #define BF_BANNERVER BF_NAME" "BF_VERSION"/"BF_OS From 8261016c7ee753b48bc6c73e030fb10fadd9661f Mon Sep 17 00:00:00 2001 From: Alexey Khromov Date: Mon, 14 Apr 2025 21:28:49 +0300 Subject: [PATCH 6/7] README.md fix --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4d94a81..38ef0b3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +![master branch](https://prj.zxalexis.ru/gitea/zx/bforce/actions/workflows/debpkg.yaml/badge.svg?branch=master) ![master branch](https://prj.zxalexis.ru/gitea/zx/bforce/actions/workflows/arch.yaml/badge.svg?branch=master) BinkleyForce FTN mailer From 07edf66b72b5656bf114a56e20fd521dc65f6754 Mon Sep 17 00:00:00 2001 From: Alexey Khromov Date: Tue, 15 Apr 2025 00:25:59 +0300 Subject: [PATCH 7/7] Fixed some lint errors from cppcheck --- source/bforce/expression.tab.c | 5 ++++- source/bforce/expression.y | 4 +++- source/bforce/logger.c | 22 +++++++++++----------- source/bforce/os_unix.c | 16 ++++++++++++---- source/include/logger.h | 6 +++--- 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/source/bforce/expression.tab.c b/source/bforce/expression.tab.c index 888251c..13f154b 100644 --- a/source/bforce/expression.tab.c +++ b/source/bforce/expression.tab.c @@ -950,7 +950,7 @@ int yydebug; `-----------------------------------------------*/ static void -yydestruct (const char *yymsg, +yydestruct (char *yymsg, yysymbol_kind_t yykind, YYSTYPE *yyvaluep) { YY_USE (yyvaluep); @@ -1059,6 +1059,7 @@ yysetstate: /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ + YYSTYPE *yyls1 = yyls; yy_state_t *yyss1 = yyss; YYSTYPE *yyvs1 = yyvs; @@ -1069,7 +1070,9 @@ yysetstate: yyoverflow (YY_("memory exhausted"), &yyss1, yysize * YYSIZEOF (*yyssp), &yyvs1, yysize * YYSIZEOF (*yyvsp), + &yyls1, yysize * YYSIZEOF (*yylsp), &yystacksize); + yyls = yyls1; yyss = yyss1; yyvs = yyvs1; } diff --git a/source/bforce/expression.y b/source/bforce/expression.y index 34f7a8f..0dd88b7 100644 --- a/source/bforce/expression.y +++ b/source/bforce/expression.y @@ -360,7 +360,8 @@ static int expr_check_mailer(const char *str) static int expr_check_addr(const char *str) { - s_faddr addr; + s_faddr addr = { 0, 0, 0, 0, 0, '\0' }; + #ifdef DEBUG char abuf1[BF_MAXADDRSTR+1]; char abuf2[BF_MAXADDRSTR+1]; @@ -368,6 +369,7 @@ static int expr_check_addr(const char *str) DEB((D_EVENT, "[yacc] addr: \"%s\" (session with \"%s\")", ftn_addrstr(abuf1, addr), ftn_addrstr(abuf2, state.node.addr))); + #endif if( !state.valid ) diff --git a/source/bforce/logger.c b/source/bforce/logger.c index d62d35b..40783cb 100644 --- a/source/bforce/logger.c +++ b/source/bforce/logger.c @@ -172,7 +172,7 @@ int log_reopen(const char *logname, const char *ext, const char *tty) } -int log(const char *s, ...) +void log(const char *s, ...) { char timestr[40]; @@ -212,10 +212,10 @@ int log(const char *s, ...) va_end(args); - return 0; + //return 0; } -int logerr(const char *s, ...) +void logerr(const char *s, ...) { char timestr[40]; va_list args; @@ -281,7 +281,7 @@ int logerr(const char *s, ...) va_end(args); - return 0; + //return 0; } #endif /* USE_SYSLOG */ @@ -308,7 +308,7 @@ int log_open(const char *logname, const char *ext, const char *tty) p = xstrcat(p, BF_VERSION); int fac = conf_number(cf_syslog_facility); if( tty && *tty ) - strncpy(p, tty, sizeof(p)); + strncpy(p, tty, strlen(p)); openlog(p, LOG_PID, fac); slog_active = TRUE; return 0; @@ -330,7 +330,7 @@ int log_close(void) } -int log(const char *s, ...) +void log(const char *s, ...) { char timestr[40]; @@ -357,10 +357,10 @@ int log(const char *s, ...) va_end(args); - return 0; + //return 0; } -int logerr(const char *s, ...) +void logerr(const char *s, ...) { char timestr[40]; @@ -379,7 +379,7 @@ int logerr(const char *s, ...) va_end(args); - return 0; +// return 0; } #endif /* USE_SYSLOG */ @@ -530,7 +530,7 @@ int debug_close(void) return rc; } -int debug(unsigned long what, const char *str, ...) +void debug(unsigned long what, const char *str, ...) { char buf[40]; va_list args; @@ -554,7 +554,7 @@ int debug(unsigned long what, const char *str, ...) } } - return 0; + //return 0; } #endif /* DEBUG */ diff --git a/source/bforce/os_unix.c b/source/bforce/os_unix.c index 442198a..36317d2 100644 --- a/source/bforce/os_unix.c +++ b/source/bforce/os_unix.c @@ -152,6 +152,7 @@ int exec_redirect_descriptor(int desc, const char *fname, int flags) { log("exec error: cannot open \"%s\" <--> %d (got %d)", fname, desc, fd); + close(fd); return -1; } @@ -329,7 +330,8 @@ int xsystem(const char *command, const char *p_input, const char *p_output) { pid_t pid; int status; - + int fd; + ASSERT(command != NULL); DEB((D_INFO, "xsystem: command \"%s\", input \"%s\", output \"%s\"", @@ -342,27 +344,33 @@ int xsystem(const char *command, const char *p_input, const char *p_output) if( p_input ) { close(0); - if( open(p_input, O_RDONLY) != 0 ) + fd = open(p_input, O_RDONLY); + if( fd != 0 ) { logerr("can't open stdin \"%s\"", p_input); + close(fd); exit(-1); } } if( p_output ) { close(1); - if( open(p_output, O_WRONLY|O_APPEND|O_CREAT, 0600) != 1 ) + fd = open(p_output, O_WRONLY|O_APPEND|O_CREAT, 0600); + if( fd != 1 ) { logerr("can't open stdout \"%s\"", p_output); + close(fd); exit(-1); } } if( p_output ) { close(2); - if( open(p_output, O_WRONLY|O_APPEND|O_CREAT, 0600) != 2 ) + fd = open(p_output, O_WRONLY|O_APPEND|O_CREAT, 0600); + if( fd != 2 ) { logerr("can't open stderr \"%s\"", p_output); + close(fd); exit(-1); } } diff --git a/source/include/logger.h b/source/include/logger.h index 0dfb479..7f13b53 100644 --- a/source/include/logger.h +++ b/source/include/logger.h @@ -65,8 +65,8 @@ void log_setident(const char *ident); int log_open(const char *logname, const char *ext, const char *tty); int log_close(void); int log_reopen(const char *logname, const char *ext, const char *tty); -int log(const char *s, ...); -int logerr(const char *s, ...); +void log(const char *s, ...); +void logerr(const char *s, ...); #ifdef DEBUG //void debug_setlevel(long newlevel, bool logit); @@ -75,7 +75,7 @@ bool debug_isopened(void); //int debug_parsestring(char *str, unsigned long *deblevel); int debug_open(); int debug_close(); -int debug(unsigned long what, const char *str, ...); +void debug(unsigned long what, const char *str, ...); void debug_configure(); #endif