;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2017 David Hashe ;;; Copyright © 2017 Kei Kebreau ;;; Copyright © 2020 Eric Bavier ;;; Copyright © 2021 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu packages pascal) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages) #:use-module (guix download) #:use-module (guix utils) #:use-module (guix build-system gnu) #:use-module (gnu packages) #:use-module (gnu packages base) #:use-module (gnu packages bootstrap) #:use-module (gnu packages commencement) #:use-module (gnu packages compression) #:use-module (gnu packages gcc) #:use-module (gnu packages ncurses) #:use-module (gnu packages perl) #:use-module (gnu packages xml) #:use-module (ice-9 match)) (define %fpc-version "3.2.2") (define %fpc-release-date "2021/05/19") ;;; FIXME: Bootstrap properly; these are prebuilt binaries. (define fpc-bootstrap-i386 (origin (method url-fetch) (uri (string-append "mirror://sourceforge/freepascal/Linux/" %fpc-version "/fpc-" %fpc-version ".i386-linux.tar")) (sha256 (base32 "0n4r85dsr86zlk7r4hbd4nj14sda6rwgdgzxg4gj4q981fn80agn")))) (define fpc-booFrom b0716eac4e800a0ea53e1b949250f671702f28a0 Mon Sep 17 00:00:00 2001 From: Tom Callaway <spot@fedoraproject.org> Date: Tue, 30 Oct 2012 15:39:24 -0400 Subject: apply workaround to CVE-2012-4527 --- mcrypt-2.6.8.orig/src/mcrypt.c +++ mcrypt-2.6.8/src/mcrypt.c @@ -41,6 +41,8 @@ # include <time.h> #endif +#define WIDTH 80 + static char rcsid[] = "$Id: mcrypt.c,v 1.2 2007/11/07 17:10:21 nmav Exp $"; @@ -482,7 +484,7 @@ #ifdef HAVE_STAT if (stream_flag == FALSE) { if (is_normal_file(file[i]) == FALSE) { - sprintf(tmperr, + snprintf(tmperr, WIDTH, _ ("%s: %s is not a regular file. Skipping...\n"), program_name, file[i]); @@ -501,7 +503,7 @@ dinfile = file[i]; if ((isatty(fileno((FILE *) (stdin))) == 1) && (stream_flag == TRUE) && (force == 0)) { /* not a tty */ - sprintf(tmperr, + snprintf(tmperr, WIDTH, _ ("%s: Encrypted data will not be read from a terminal.\n"), program_name); @@ -520,7 +522,7 @@ einfile = file[i]; if ((isatty(fileno((FILE *) (stdout))) == 1) && (stream_flag == TRUE) && (force == 0)) { /* not a tty */ - sprintf(tmperr, + snprintf(tmperr, WIDTH, _ ("%s: Encrypted data will not be written to a terminal.\n"), program_name); @@ -544,7 +546,7 @@ strcpy(outfile, einfile); /* if file has already the .nc ignore it */ if (strstr(outfile, ".nc") != NULL) { - sprintf(tmperr, + snprintf(tmperr, WIDTH, _ ("%s: file %s has the .nc suffix... skipping...\n"), program_name, outfile); @@ -590,10 +592,10 @@ if (x == 0) { if (stream_flag == FALSE) { - sprintf(tmperr, _("File %s was decrypted.\n"), dinfile); + snprintf(tmperr, WIDTH, _("File %s was decrypted.\n"), dinfile); err_warn(tmperr); } else { - sprintf(tmperr, _("Stdin was decrypted.\n")); + snprintf(tmperr, WIDTH, _("Stdin was decrypted.\n")); err_warn(tmperr); } #ifdef HAVE_STAT @@ -610,7 +612,7 @@ } else { if (stream_flag == FALSE) { - sprintf(tmperr, + snprintf(tmperr, WIDTH, _ ("File %s was NOT decrypted successfully.\n"), dinfile); @@ -636,10 +638,10 @@ if (x == 0) { if (stream_flag == FALSE) { - sprintf(tmperr, _("File %s was encrypted.\n"), einfile); + snprintf(tmperr, WIDTH, _("File %s was encrypted.\n"), einfile); err_warn(tmperr); } else { - sprintf(tmperr, _("Stdin was encrypted.\n")); + snprintf(tmperr, WIDTH, _("Stdin was encrypted.\n")); err_warn(tmperr); } #ifdef HAVE_STAT @@ -655,7 +657,7 @@ } else { if (stream_flag == FALSE) { - sprintf(tmperr, + snprintf(tmperr, WIDTH, _ ("File %s was NOT encrypted successfully.\n"), einfile); - git v0.12 (string-append "utils-fpcm." arch "-linux.tar.gz"))) ;; Only the base compiler and fpcmake are needed. (invoke "tar" "xvf" binary-tarball compiler-tarball fpcmake-tarball) (invoke "tar" "xvf" compiler-tarball "-C..") (invoke "tar" "xvf" fpcmake-tarball "-C.."))))) (add-after 'patch-source-shebangs 'patch-inline-shebangs (lambda _ (substitute* "fpcsrc/compiler/cscript.pas" (("#!/bin/sh") (string-append "#!" (which "sh")))))) (add-before 'build 'patch-release-date (lambda _ ; reproducibility (substitute* (list "fpcdocs/prog.tex" "fpcsrc/packages/amunits/examples/sortdemo.pas" "fpcsrc/packages/libogcfpc/src/ogc/libversion.inc" "fpcsrc/utils/fpcres/fpcjres.pas" "fpcsrc/utils/fpcres/fpcres.pas" "fpcsrc/utils/fpcm/fpcmmain.pp" "fpcsrc/utils/fpcreslipo/fpcreslipo.pp" "fpcsrc/compiler/version.pas") (("\\{\\$I(NCLUDE)? %DATE%\\}") (format #f "'~a'" ,%fpc-release-date))))) (replace 'configure (lambda* (#:key inputs outputs #:allow-other-keys) (substitute* "fpcsrc/compiler/systems/t_linux.pas" ;; Point to the current glibc dynamic linker. (("/lib/ld-linux.so.2") (search-input-file inputs ,(glibc-dynamic-linker))) (("/lib64/ld-linux-x86-64.so.2") (search-input-file inputs ,(glibc-dynamic-linker))) ; TODO: /lib/ld-linux-armhf.so.3 ; TODO: /lib/ld-linux-aarch64.so.1 ; TODO: /lib64/ld64.so.2 ;; Add glibc to ld's search path. (("if \\(isdll\\) then") (string-append "Add('SEARCH_DIR(\"" (assoc-ref inputs "libc") "/lib" "\")');\n" "if (isdll) then"))) (substitute* "fpcsrc/compiler/options.pas" (("exepath\\+'../etc/'") (string-append "'" (assoc-ref outputs "out") "/etc'"))))) (replace 'build (lambda* (#:key inputs #:allow-other-keys) (let* ((fpc-bin (string-append fpc-bootstrap-path "/bin")) (fpc (string-append fpc-bin "/fpc")) (fpcmake (string-append fpc-bin "/fpcmake"))) ;; The fpc binary needs to run the ppc[arch] binary (which ;; does the actual compiling) in this directory. (setenv "PATH" (string-append (getenv "PATH") ":" fpc-bootstrap-path "/lib/fpc/" ,version)) (setenv "FPC" fpc) ;; Specify target operating system using "-T" option (invoke fpcmake (string-append "-T" arch "-linux")) (invoke "make" "build" "NOGDB=1")))) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) ;; This is the suffix of the ppc[arch] binary. (suffix (if (string= arch "x86_64") "x64" "386")) (ppc (string-append "ppc" suffix))) (invoke "make" "install" "NOGDB=1" (string-append "INSTALL_PREFIX=" out)) ;; Remove files that fail RUNPATH validation. ;; TODO: Fix it instead. (delete-file (string-append out "/lib/libpas2jslib.so")) ;; Add a symlink to the ppc[arch] binary so fpc works. (symlink (string-append out "/lib/fpc/" ,version "/" ppc) (string-append out "/bin/" ppc)) ;; Install the example configuration file. (mkdir (string-append out "/etc")) (invoke (string-append out "/lib/fpc/" ,version "/samplecfg") (string-append out "/lib/fpc/" ,version) (string-append out "/etc"))))) (add-after 'install 'wrap (lambda* (#:key inputs outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (fpc (string-append out "/bin/fpc")) (ld (assoc-ref inputs "ld-wrapper")) (glibc (assoc-ref inputs "glibc"))) (wrap-program fpc `("PATH" ":" prefix (,(string-append ld "/bin"))) `("LIBRARY_PATH" ":" prefix (,(string-append glibc "/lib"))))))))))) ;; fpc invokes gcc, so make sure LIBRARY_PATH et.al are set. ;(native-search-paths (package-native-search-paths gcc)) (home-page "https://www.freepascal.org") (synopsis "The Free Pascal Compiler") (description "Free Pascal is a professional Object Pascal compiler. It supports the Turbo Pascal 7.0, Delphi, and Mac Pascal dialects. Free Pascal also supports many useful extensions to the Pascal programming language.") ;; The majority of the software included is licensed under the GPLv2 ;; or later. For more licensing details, see the appropriate files in ;; the install/doc directory of the source distribution. (license license:gpl2+))) (define-public p2c (package (name "p2c") (version "2.01") (source (origin (method url-fetch) (uri (string-append "https://alum.mit.edu/www/toms/p2c/p2c-" version ".tar.gz")) (sha256 (base32 "03x72lv6jrvikbrpz4kfq1xp61l2jw5ki6capib71lxs65zndajn")))) (build-system gnu-build-system) (arguments `(#:make-flags (let ((out (assoc-ref %outputs "out"))) (list (string-append "CC=" ,(cc-for-target)) (string-append "HOMEDIR=" out "/lib/p2c") (string-append "INCDIR=" out "/include/p2c") (string-append "BINDIR=" out "/bin") (string-append "LIBDIR=" out "/lib") (string-append "MANDIR=" out "/share/man/man1") "MANFILE=p2c.man.inst")) #:test-target "test" #:phases (modify-phases %standard-phases (delete 'configure) (add-before 'build 'mkdir (lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) (mkdir-p (string-append out "/share/man")) (mkdir-p (string-append out "/lib")) (mkdir-p (string-append out "/bin")) (mkdir-p (string-append out "/include"))) #t)) (add-before 'build 'chdir (lambda* (#:key make-flags #:allow-other-keys) (chdir "src") #t))))) (native-inputs (list perl which)) (synopsis "p2c converts Pascal programs to C programs--which you can then compile using gcc") (description "This package provides @command{p2c}, a program to convert Pascal source code to C source code, and @command{p2cc}, a compiler for Pascal programs.") (home-page "http://users.fred.net/tds/lab/p2c/") (license license:gpl2+)))