Mageia Bugzilla – Attachment 8547 Details for
Bug 19571
overflow when querying for size with urpmq
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
patch for the full largefile 64bit support using Math::Int64
perl-URPM-overflow-full64bit-new.patch (text/plain), 12.53 KB, created by
Giuseppe Ghibò
on 2016-10-16 15:36:10 CEST
(
hide
)
Description:
patch for the full largefile 64bit support using Math::Int64
Filename:
MIME Type:
Creator:
Giuseppe Ghibò
Created:
2016-10-16 15:36:10 CEST
Size:
12.53 KB
patch
obsolete
>diff -up URPM-5.08/Makefile.PL.largefile URPM-5.08/Makefile.PL >--- URPM-5.08/Makefile.PL.largefile 2014-11-14 13:15:52.000000000 +0100 >+++ URPM-5.08/Makefile.PL 2016-10-16 15:01:04.438868126 +0200 >@@ -41,6 +41,9 @@ my $commonusername = "../common/"; > > sub MY::postamble { > <<"**MM**"; >+ppport.h: >+ perl -MDevel::PPPort -e Devel::PPPort::WriteFile >+ > .PHONY: ChangeLog > > ChangeLog: >@@ -71,4 +74,5 @@ WriteMakefile( > INC => '-I/usr/include/rpm', > dist => { COMPRESS => "xz -f", SUFFIX => ".xz" }, > realclean => { FILES => "t/RPMS/noarch/*" }, >+ H => [ qw(ppport.h) ], > ); >diff -up URPM-5.08/perl_math_int64.c.largefile URPM-5.08/perl_math_int64.c >--- URPM-5.08/perl_math_int64.c.largefile 2016-10-16 14:16:06.984727325 +0200 >+++ URPM-5.08/perl_math_int64.c 2016-01-04 10:07:20.000000000 +0100 >@@ -0,0 +1,134 @@ >+/* >+ * perl_math_int64.c - This file is in the public domain >+ * Author: "Salvador Fandino <sfandino@yahoo.com>, Dave Rolsky <autarch@urth.org>" >+ * >+ * Generated on: 2016-01-04 10:07:18 >+ * Math::Int64 version: 0.54 >+ * Module::CAPIMaker version: >+ */ >+ >+#include "EXTERN.h" >+#include "perl.h" >+#include "ppport.h" >+ >+#ifdef __MINGW32__ >+#include <stdint.h> >+#endif >+ >+#ifdef _MSC_VER >+#include <stdlib.h> >+typedef __int64 int64_t; >+typedef unsigned __int64 uint64_t; >+#endif >+ >+/* you may need to add a typemap for int64_t here if it is not defined >+ by default in your C header files */ >+ >+HV *math_int64_c_api_hash; >+int math_int64_c_api_min_version; >+int math_int64_c_api_max_version; >+ >+int64_t (*math_int64_c_api_SvI64)(pTHX_ SV*); >+int (*math_int64_c_api_SvI64OK)(pTHX_ SV*); >+uint64_t (*math_int64_c_api_SvU64)(pTHX_ SV*); >+int (*math_int64_c_api_SvU64OK)(pTHX_ SV*); >+SV * (*math_int64_c_api_newSVi64)(pTHX_ int64_t); >+SV * (*math_int64_c_api_newSVu64)(pTHX_ uint64_t); >+uint64_t (*math_int64_c_api_randU64)(pTHX); >+ >+int >+perl_math_int64_load(int required_version) { >+ dTHX; >+ SV **svp; >+ eval_pv("require Math::Int64", TRUE); >+ if (SvTRUE(ERRSV)) return 0; >+ >+ math_int64_c_api_hash = get_hv("Math::Int64::C_API", 0); >+ if (!math_int64_c_api_hash) { >+ sv_setpv(ERRSV, "Unable to load Math::Int64 C API"); >+ SvSETMAGIC(ERRSV); >+ return 0; >+ } >+ >+ svp = hv_fetch(math_int64_c_api_hash, "min_version", 11, 0); >+ if (!svp) svp = hv_fetch(math_int64_c_api_hash, "version", 7, 1); >+ if (!svp || !*svp) { >+ sv_setpv(ERRSV, "Unable to retrieve C API version for Math::Int64"); >+ SvSETMAGIC(ERRSV); >+ return 0; >+ } >+ math_int64_c_api_min_version = SvIV(*svp); >+ >+ svp = hv_fetch(math_int64_c_api_hash, "max_version", 11, 0); >+ if (!svp) svp = hv_fetch(math_int64_c_api_hash, "version", 7, 1); >+ if (!svp || !*svp) { >+ sv_setpv(ERRSV, "Unable to retrieve C API version for Math::Int64"); >+ SvSETMAGIC(ERRSV); >+ return 0; >+ } >+ math_int64_c_api_max_version = SvIV(*svp); >+ >+ if ((required_version < math_int64_c_api_min_version) || >+ (required_version > math_int64_c_api_max_version)) { >+ sv_setpvf(ERRSV, >+ "Math::Int64 C API version mismatch. " >+ "The installed module supports versions %d to %d but %d is required", >+ math_int64_c_api_min_version, >+ math_int64_c_api_max_version, >+ required_version); >+ SvSETMAGIC(ERRSV); >+ return 0; >+ } >+ >+ svp = hv_fetch(math_int64_c_api_hash, "SvI64", 5, 0); >+ if (!svp || !*svp) { >+ sv_setpv(ERRSV, "Unable to fetch pointer 'SvI64' C function from Math::Int64"); >+ SvSETMAGIC(ERRSV); >+ return 0; >+ } >+ math_int64_c_api_SvI64 = INT2PTR(void *, SvIV(*svp)); >+ svp = hv_fetch(math_int64_c_api_hash, "SvI64OK", 7, 0); >+ if (!svp || !*svp) { >+ sv_setpv(ERRSV, "Unable to fetch pointer 'SvI64OK' C function from Math::Int64"); >+ SvSETMAGIC(ERRSV); >+ return 0; >+ } >+ math_int64_c_api_SvI64OK = INT2PTR(void *, SvIV(*svp)); >+ svp = hv_fetch(math_int64_c_api_hash, "SvU64", 5, 0); >+ if (!svp || !*svp) { >+ sv_setpv(ERRSV, "Unable to fetch pointer 'SvU64' C function from Math::Int64"); >+ SvSETMAGIC(ERRSV); >+ return 0; >+ } >+ math_int64_c_api_SvU64 = INT2PTR(void *, SvIV(*svp)); >+ svp = hv_fetch(math_int64_c_api_hash, "SvU64OK", 7, 0); >+ if (!svp || !*svp) { >+ sv_setpv(ERRSV, "Unable to fetch pointer 'SvU64OK' C function from Math::Int64"); >+ SvSETMAGIC(ERRSV); >+ return 0; >+ } >+ math_int64_c_api_SvU64OK = INT2PTR(void *, SvIV(*svp)); >+ svp = hv_fetch(math_int64_c_api_hash, "newSVi64", 8, 0); >+ if (!svp || !*svp) { >+ sv_setpv(ERRSV, "Unable to fetch pointer 'newSVi64' C function from Math::Int64"); >+ SvSETMAGIC(ERRSV); >+ return 0; >+ } >+ math_int64_c_api_newSVi64 = INT2PTR(void *, SvIV(*svp)); >+ svp = hv_fetch(math_int64_c_api_hash, "newSVu64", 8, 0); >+ if (!svp || !*svp) { >+ sv_setpv(ERRSV, "Unable to fetch pointer 'newSVu64' C function from Math::Int64"); >+ SvSETMAGIC(ERRSV); >+ return 0; >+ } >+ math_int64_c_api_newSVu64 = INT2PTR(void *, SvIV(*svp)); >+ svp = hv_fetch(math_int64_c_api_hash, "randU64", 7, 0); >+ if (!svp || !*svp) { >+ sv_setpv(ERRSV, "Unable to fetch pointer 'randU64' C function from Math::Int64"); >+ SvSETMAGIC(ERRSV); >+ return 0; >+ } >+ math_int64_c_api_randU64 = INT2PTR(void *, SvIV(*svp)); >+ >+ return 1; >+} >diff -up URPM-5.08/perl_math_int64.h.largefile URPM-5.08/perl_math_int64.h >--- URPM-5.08/perl_math_int64.h.largefile 2016-10-16 14:16:12.605729361 +0200 >+++ URPM-5.08/perl_math_int64.h 2016-01-04 10:07:20.000000000 +0100 >@@ -0,0 +1,67 @@ >+/* >+ * perl_math_int64.h - This file is in the public domain >+ * Author: "Salvador Fandino <sfandino@yahoo.com>, Dave Rolsky <autarch@urth.org>" >+ * Version: 2.1 >+ * >+ * Generated on: 2016-01-04 10:07:18 >+ * Math::Int64 version: 0.54 >+ * Module::CAPIMaker version: >+ */ >+ >+#if !defined (PERL_MATH_INT64_H_INCLUDED) >+#define PERL_MATH_INT64_H_INCLUDED >+ >+#define MATH_INT64_C_API_REQUIRED_VERSION 2 >+#define MATH_INT64_VERSION MATH_INT64_C_API_REQUIRED_VERSION >+ >+int perl_math_int64_load(int required_version); >+ >+#define PERL_MATH_INT64_LOAD perl_math_int64_load(MATH_INT64_C_API_REQUIRED_VERSION) >+#define PERL_MATH_INT64_LOAD_OR_CROAK \ >+ if (PERL_MATH_INT64_LOAD); \ >+ else croak(NULL); >+#define MATH_INT64_BOOT PERL_MATH_INT64_LOAD_OR_CROAK >+ >+extern HV *math_int64_c_api_hash; >+extern int math_int64_c_api_min_version; >+extern int math_int64_c_api_max_version; >+#define math_int64_capi_version math_int64_c_api_max_version >+ >+#if (defined(MATH_INT64_NATIVE_IF_AVAILABLE) && (IVSIZE == 8)) >+#define MATH_INT64_NATIVE 1 >+#endif >+ >+extern int64_t (*math_int64_c_api_SvI64)(pTHX_ SV*); >+#define SvI64(a) ((*math_int64_c_api_SvI64)(aTHX_ (a))) >+extern int (*math_int64_c_api_SvI64OK)(pTHX_ SV*); >+#define SvI64OK(a) ((*math_int64_c_api_SvI64OK)(aTHX_ (a))) >+extern uint64_t (*math_int64_c_api_SvU64)(pTHX_ SV*); >+#define SvU64(a) ((*math_int64_c_api_SvU64)(aTHX_ (a))) >+extern int (*math_int64_c_api_SvU64OK)(pTHX_ SV*); >+#define SvU64OK(a) ((*math_int64_c_api_SvU64OK)(aTHX_ (a))) >+extern SV * (*math_int64_c_api_newSVi64)(pTHX_ int64_t); >+#define newSVi64(a) ((*math_int64_c_api_newSVi64)(aTHX_ (a))) >+extern SV * (*math_int64_c_api_newSVu64)(pTHX_ uint64_t); >+#define newSVu64(a) ((*math_int64_c_api_newSVu64)(aTHX_ (a))) >+extern uint64_t (*math_int64_c_api_randU64)(pTHX); >+#define randU64() ((*math_int64_c_api_randU64)(aTHX)) >+ >+ >+#if MATH_INT64_NATIVE >+ >+#undef newSVi64 >+#define newSVi64 newSViv >+#undef newSVu64 >+#define newSVu64 newSVuv >+ >+#define sv_seti64 sv_setiv_mg >+#define sv_setu64 sv_setuv_mg >+ >+#else >+ >+#define sv_seti64(target, i64) (sv_setsv_mg(target, sv_2mortal(newSVi64(i64)))) >+#define sv_setu64(target, u64) (sv_setsv_mg(target, sv_2mortal(newSVu64(u64)))) >+ >+#endif >+ >+#endif >\ No newline at end of file >diff -up URPM-5.08/typemap.largefile URPM-5.08/typemap >--- URPM-5.08/typemap.largefile 2013-09-01 02:54:04.000000000 +0200 >+++ URPM-5.08/typemap 2016-10-15 22:13:30.000000000 +0200 >@@ -1,3 +1,14 @@ > URPM::DB T_PTROBJ > URPM::Transaction T_PTROBJ > URPM::Package T_PTROBJ >+ >+TYPEMAP >+uint64_t T_U_LONG_LONG >+ >+INPUT >+T_U_LONG_LONG >+ $var = SvU64($arg) >+ >+OUTPUT >+T_U_LONG_LONG >+ $arg = newSVu64($var); >diff -up URPM-5.08/URPM.pm.largefile URPM-5.08/URPM.pm >--- URPM-5.08/URPM.pm.largefile 2016-10-14 10:53:51.000000000 +0200 >+++ URPM-5.08/URPM.pm 2016-10-16 14:37:09.369277146 +0200 >@@ -3,6 +3,9 @@ package URPM; > use strict; > use warnings; > use DynaLoader; >+# >+# is this needed? >+#use Math::Int64; > > # different files, but same package > # require them here to avoid dependencies >diff -up URPM-5.08/URPM.xs.largefile URPM-5.08/URPM.xs >--- URPM-5.08/URPM.xs.largefile 2016-10-16 13:33:42.000000000 +0200 >+++ URPM-5.08/URPM.xs 2016-10-16 15:17:21.003206234 +0200 >@@ -11,6 +11,11 @@ > #include "EXTERN.h" > #include "perl.h" > #include "XSUB.h" >+#include "ppport.h" >+ >+/*#define MATH_INT64_NATIVE_IF_AVAILABLE*/ >+#include "perl_math_int64.h" >+#include "perl_math_int64.c" > > #include <sys/utsname.h> > #include <sys/select.h> >@@ -46,7 +51,7 @@ typedef struct rpmSpec_s * Spec; > > struct s_Package { > Header h; >- int filesize; >+ uint64_t filesize; > unsigned flag; > char *info; > char *requires; >@@ -209,9 +214,18 @@ get_int(const Header header, rpmTag tag) > return rpmtdGetNumber(&val); > } > >-static size_t >+static uint64_t >+get_int2(const Header header, rpmTag newtag, rpmTag oldtag) { >+ struct rpmtd_s val; >+ >+ if (!headerGet(header, newtag, &val, HEADERGET_DEFAULT)) >+ headerGet(header, oldtag, &val, HEADERGET_DEFAULT); >+ return rpmtdGetNumber(&val); >+} >+ >+static uint64_t > get_filesize(const Header h) { >- return headerGetNumber(h, RPMTAG_SIGSIZE) + 440; /* 440 is the rpm header size (?) empirical, but works */ >+ return get_int2(h, RPMTAG_LONGSIGSIZE, RPMTAG_SIGSIZE) + 440; /* 440 is the rpm header size (?) empirical, but works */ > } > > static int >@@ -758,7 +772,7 @@ pack_header(const URPM__Package pkg) { > const char *nvr = headerGetAsString(pkg->h, RPMTAG_NVR); > const char *arch = get_arch(pkg->h); > p += 1 + snprintf(buff, sizeof(buff), "%s.%s@%llu@%llu@%s", nvr, arch, >- get_int(pkg->h, RPMTAG_EPOCH), get_int(pkg->h, RPMTAG_SIZE), >+ (long long unsigned int) get_int(pkg->h, RPMTAG_EPOCH), (long long unsigned int) get_int2(pkg->h, RPMTAG_LONGSIZE, RPMTAG_SIZE), > get_name(pkg->h, RPMTAG_GROUP)); > pkg->info = memcpy(malloc(p-buff), buff, p-buff); > } >@@ -1047,7 +1061,7 @@ parse_line(AV *depslist, HV *provides, H > // reset package, next line will be for another one > memset(pkg, 0, sizeof(struct s_Package)); > } else if (!strcmp(tag, "filesize")) >- pkg->filesize = atoi(data); >+ pkg->filesize = atoll(data); > else { > char **ptr = NULL; > if (!strcmp(tag, "requires")) >@@ -1751,7 +1765,7 @@ Pkg_compare(pkg, evr) > OUTPUT: > RETVAL > >-int >+uint64_t > Pkg_size(pkg) > URPM::Package pkg > CODE: >@@ -1761,12 +1775,12 @@ Pkg_size(pkg) > if ((s = strchr(pkg->info, '@')) != NULL && (s = strchr(s+1, '@')) != NULL) { > if ((eos = strchr(s+1, '@')) != NULL) > *eos = 0; /* mark end of string to enable searching backwards */ >- RETVAL = atoi(s+1); >+ RETVAL = atoll(s+1); > if (eos != NULL) *eos = '@'; > } else > RETVAL = 0; > } else if (pkg->h) >- RETVAL = get_int(pkg->h, RPMTAG_SIZE); >+ RETVAL = get_int2(pkg->h, RPMTAG_LONGSIZE, RPMTAG_SIZE); > else > RETVAL = 0; > OUTPUT: >@@ -1775,11 +1789,11 @@ Pkg_size(pkg) > void > Pkg_set_filesize(pkg, filesize) > URPM::Package pkg >- size_t filesize; >+ uint64_t filesize; > PPCODE: > pkg->filesize = filesize; > >-int >+uint64_t > Pkg_filesize(pkg) > URPM::Package pkg > CODE: >@@ -2087,7 +2101,7 @@ Pkg_build_info(pkg, fileno, provides_fil > CODE: > if (pkg->info) { > char buff[65536*2]; >- size_t size; >+ uint64_t size; > > /* info line should be the last to be written */ > if (pkg->provides && *pkg->provides) { >@@ -2121,7 +2135,7 @@ Pkg_build_info(pkg, fileno, provides_fil > if (size < sizeof(buff)) write_nocheck(fileno, buff, size); > } > if (pkg->filesize) { >- size = snprintf(buff, sizeof(buff), "@filesize@%d\n", pkg->filesize); >+ size = snprintf(buff, sizeof(buff), "@filesize@%llu\n", (long long unsigned int) pkg->filesize); > if (size < sizeof(buff)) write_nocheck(fileno, buff, size); > } > size = snprintf(buff, sizeof(buff), "@info@%s\n", pkg->info); >@@ -2755,6 +2769,7 @@ MODULE = URPM PACKAGE = URPM > > BOOT: > (void) read_config_files(0); >+ PERL_MATH_INT64_LOAD_OR_CROAK; > > void > Urpm_bind_rpm_textdomain_codeset()
diff -up URPM-5.08/Makefile.PL.largefile URPM-5.08/Makefile.PL --- URPM-5.08/Makefile.PL.largefile 2014-11-14 13:15:52.000000000 +0100 +++ URPM-5.08/Makefile.PL 2016-10-16 15:01:04.438868126 +0200 @@ -41,6 +41,9 @@ my $commonusername = "../common/"; sub MY::postamble { <<"**MM**"; +ppport.h: + perl -MDevel::PPPort -e Devel::PPPort::WriteFile + .PHONY: ChangeLog ChangeLog: @@ -71,4 +74,5 @@ WriteMakefile( INC => '-I/usr/include/rpm', dist => { COMPRESS => "xz -f", SUFFIX => ".xz" }, realclean => { FILES => "t/RPMS/noarch/*" }, + H => [ qw(ppport.h) ], ); diff -up URPM-5.08/perl_math_int64.c.largefile URPM-5.08/perl_math_int64.c --- URPM-5.08/perl_math_int64.c.largefile 2016-10-16 14:16:06.984727325 +0200 +++ URPM-5.08/perl_math_int64.c 2016-01-04 10:07:20.000000000 +0100 @@ -0,0 +1,134 @@ +/* + * perl_math_int64.c - This file is in the public domain + * Author: "Salvador Fandino <sfandino@yahoo.com>, Dave Rolsky <autarch@urth.org>" + * + * Generated on: 2016-01-04 10:07:18 + * Math::Int64 version: 0.54 + * Module::CAPIMaker version: + */ + +#include "EXTERN.h" +#include "perl.h" +#include "ppport.h" + +#ifdef __MINGW32__ +#include <stdint.h> +#endif + +#ifdef _MSC_VER +#include <stdlib.h> +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#endif + +/* you may need to add a typemap for int64_t here if it is not defined + by default in your C header files */ + +HV *math_int64_c_api_hash; +int math_int64_c_api_min_version; +int math_int64_c_api_max_version; + +int64_t (*math_int64_c_api_SvI64)(pTHX_ SV*); +int (*math_int64_c_api_SvI64OK)(pTHX_ SV*); +uint64_t (*math_int64_c_api_SvU64)(pTHX_ SV*); +int (*math_int64_c_api_SvU64OK)(pTHX_ SV*); +SV * (*math_int64_c_api_newSVi64)(pTHX_ int64_t); +SV * (*math_int64_c_api_newSVu64)(pTHX_ uint64_t); +uint64_t (*math_int64_c_api_randU64)(pTHX); + +int +perl_math_int64_load(int required_version) { + dTHX; + SV **svp; + eval_pv("require Math::Int64", TRUE); + if (SvTRUE(ERRSV)) return 0; + + math_int64_c_api_hash = get_hv("Math::Int64::C_API", 0); + if (!math_int64_c_api_hash) { + sv_setpv(ERRSV, "Unable to load Math::Int64 C API"); + SvSETMAGIC(ERRSV); + return 0; + } + + svp = hv_fetch(math_int64_c_api_hash, "min_version", 11, 0); + if (!svp) svp = hv_fetch(math_int64_c_api_hash, "version", 7, 1); + if (!svp || !*svp) { + sv_setpv(ERRSV, "Unable to retrieve C API version for Math::Int64"); + SvSETMAGIC(ERRSV); + return 0; + } + math_int64_c_api_min_version = SvIV(*svp); + + svp = hv_fetch(math_int64_c_api_hash, "max_version", 11, 0); + if (!svp) svp = hv_fetch(math_int64_c_api_hash, "version", 7, 1); + if (!svp || !*svp) { + sv_setpv(ERRSV, "Unable to retrieve C API version for Math::Int64"); + SvSETMAGIC(ERRSV); + return 0; + } + math_int64_c_api_max_version = SvIV(*svp); + + if ((required_version < math_int64_c_api_min_version) || + (required_version > math_int64_c_api_max_version)) { + sv_setpvf(ERRSV, + "Math::Int64 C API version mismatch. " + "The installed module supports versions %d to %d but %d is required", + math_int64_c_api_min_version, + math_int64_c_api_max_version, + required_version); + SvSETMAGIC(ERRSV); + return 0; + } + + svp = hv_fetch(math_int64_c_api_hash, "SvI64", 5, 0); + if (!svp || !*svp) { + sv_setpv(ERRSV, "Unable to fetch pointer 'SvI64' C function from Math::Int64"); + SvSETMAGIC(ERRSV); + return 0; + } + math_int64_c_api_SvI64 = INT2PTR(void *, SvIV(*svp)); + svp = hv_fetch(math_int64_c_api_hash, "SvI64OK", 7, 0); + if (!svp || !*svp) { + sv_setpv(ERRSV, "Unable to fetch pointer 'SvI64OK' C function from Math::Int64"); + SvSETMAGIC(ERRSV); + return 0; + } + math_int64_c_api_SvI64OK = INT2PTR(void *, SvIV(*svp)); + svp = hv_fetch(math_int64_c_api_hash, "SvU64", 5, 0); + if (!svp || !*svp) { + sv_setpv(ERRSV, "Unable to fetch pointer 'SvU64' C function from Math::Int64"); + SvSETMAGIC(ERRSV); + return 0; + } + math_int64_c_api_SvU64 = INT2PTR(void *, SvIV(*svp)); + svp = hv_fetch(math_int64_c_api_hash, "SvU64OK", 7, 0); + if (!svp || !*svp) { + sv_setpv(ERRSV, "Unable to fetch pointer 'SvU64OK' C function from Math::Int64"); + SvSETMAGIC(ERRSV); + return 0; + } + math_int64_c_api_SvU64OK = INT2PTR(void *, SvIV(*svp)); + svp = hv_fetch(math_int64_c_api_hash, "newSVi64", 8, 0); + if (!svp || !*svp) { + sv_setpv(ERRSV, "Unable to fetch pointer 'newSVi64' C function from Math::Int64"); + SvSETMAGIC(ERRSV); + return 0; + } + math_int64_c_api_newSVi64 = INT2PTR(void *, SvIV(*svp)); + svp = hv_fetch(math_int64_c_api_hash, "newSVu64", 8, 0); + if (!svp || !*svp) { + sv_setpv(ERRSV, "Unable to fetch pointer 'newSVu64' C function from Math::Int64"); + SvSETMAGIC(ERRSV); + return 0; + } + math_int64_c_api_newSVu64 = INT2PTR(void *, SvIV(*svp)); + svp = hv_fetch(math_int64_c_api_hash, "randU64", 7, 0); + if (!svp || !*svp) { + sv_setpv(ERRSV, "Unable to fetch pointer 'randU64' C function from Math::Int64"); + SvSETMAGIC(ERRSV); + return 0; + } + math_int64_c_api_randU64 = INT2PTR(void *, SvIV(*svp)); + + return 1; +} diff -up URPM-5.08/perl_math_int64.h.largefile URPM-5.08/perl_math_int64.h --- URPM-5.08/perl_math_int64.h.largefile 2016-10-16 14:16:12.605729361 +0200 +++ URPM-5.08/perl_math_int64.h 2016-01-04 10:07:20.000000000 +0100 @@ -0,0 +1,67 @@ +/* + * perl_math_int64.h - This file is in the public domain + * Author: "Salvador Fandino <sfandino@yahoo.com>, Dave Rolsky <autarch@urth.org>" + * Version: 2.1 + * + * Generated on: 2016-01-04 10:07:18 + * Math::Int64 version: 0.54 + * Module::CAPIMaker version: + */ + +#if !defined (PERL_MATH_INT64_H_INCLUDED) +#define PERL_MATH_INT64_H_INCLUDED + +#define MATH_INT64_C_API_REQUIRED_VERSION 2 +#define MATH_INT64_VERSION MATH_INT64_C_API_REQUIRED_VERSION + +int perl_math_int64_load(int required_version); + +#define PERL_MATH_INT64_LOAD perl_math_int64_load(MATH_INT64_C_API_REQUIRED_VERSION) +#define PERL_MATH_INT64_LOAD_OR_CROAK \ + if (PERL_MATH_INT64_LOAD); \ + else croak(NULL); +#define MATH_INT64_BOOT PERL_MATH_INT64_LOAD_OR_CROAK + +extern HV *math_int64_c_api_hash; +extern int math_int64_c_api_min_version; +extern int math_int64_c_api_max_version; +#define math_int64_capi_version math_int64_c_api_max_version + +#if (defined(MATH_INT64_NATIVE_IF_AVAILABLE) && (IVSIZE == 8)) +#define MATH_INT64_NATIVE 1 +#endif + +extern int64_t (*math_int64_c_api_SvI64)(pTHX_ SV*); +#define SvI64(a) ((*math_int64_c_api_SvI64)(aTHX_ (a))) +extern int (*math_int64_c_api_SvI64OK)(pTHX_ SV*); +#define SvI64OK(a) ((*math_int64_c_api_SvI64OK)(aTHX_ (a))) +extern uint64_t (*math_int64_c_api_SvU64)(pTHX_ SV*); +#define SvU64(a) ((*math_int64_c_api_SvU64)(aTHX_ (a))) +extern int (*math_int64_c_api_SvU64OK)(pTHX_ SV*); +#define SvU64OK(a) ((*math_int64_c_api_SvU64OK)(aTHX_ (a))) +extern SV * (*math_int64_c_api_newSVi64)(pTHX_ int64_t); +#define newSVi64(a) ((*math_int64_c_api_newSVi64)(aTHX_ (a))) +extern SV * (*math_int64_c_api_newSVu64)(pTHX_ uint64_t); +#define newSVu64(a) ((*math_int64_c_api_newSVu64)(aTHX_ (a))) +extern uint64_t (*math_int64_c_api_randU64)(pTHX); +#define randU64() ((*math_int64_c_api_randU64)(aTHX)) + + +#if MATH_INT64_NATIVE + +#undef newSVi64 +#define newSVi64 newSViv +#undef newSVu64 +#define newSVu64 newSVuv + +#define sv_seti64 sv_setiv_mg +#define sv_setu64 sv_setuv_mg + +#else + +#define sv_seti64(target, i64) (sv_setsv_mg(target, sv_2mortal(newSVi64(i64)))) +#define sv_setu64(target, u64) (sv_setsv_mg(target, sv_2mortal(newSVu64(u64)))) + +#endif + +#endif \ No newline at end of file diff -up URPM-5.08/typemap.largefile URPM-5.08/typemap --- URPM-5.08/typemap.largefile 2013-09-01 02:54:04.000000000 +0200 +++ URPM-5.08/typemap 2016-10-15 22:13:30.000000000 +0200 @@ -1,3 +1,14 @@ URPM::DB T_PTROBJ URPM::Transaction T_PTROBJ URPM::Package T_PTROBJ + +TYPEMAP +uint64_t T_U_LONG_LONG + +INPUT +T_U_LONG_LONG + $var = SvU64($arg) + +OUTPUT +T_U_LONG_LONG + $arg = newSVu64($var); diff -up URPM-5.08/URPM.pm.largefile URPM-5.08/URPM.pm --- URPM-5.08/URPM.pm.largefile 2016-10-14 10:53:51.000000000 +0200 +++ URPM-5.08/URPM.pm 2016-10-16 14:37:09.369277146 +0200 @@ -3,6 +3,9 @@ package URPM; use strict; use warnings; use DynaLoader; +# +# is this needed? +#use Math::Int64; # different files, but same package # require them here to avoid dependencies diff -up URPM-5.08/URPM.xs.largefile URPM-5.08/URPM.xs --- URPM-5.08/URPM.xs.largefile 2016-10-16 13:33:42.000000000 +0200 +++ URPM-5.08/URPM.xs 2016-10-16 15:17:21.003206234 +0200 @@ -11,6 +11,11 @@ #include "EXTERN.h" #include "perl.h" #include "XSUB.h" +#include "ppport.h" + +/*#define MATH_INT64_NATIVE_IF_AVAILABLE*/ +#include "perl_math_int64.h" +#include "perl_math_int64.c" #include <sys/utsname.h> #include <sys/select.h> @@ -46,7 +51,7 @@ typedef struct rpmSpec_s * Spec; struct s_Package { Header h; - int filesize; + uint64_t filesize; unsigned flag; char *info; char *requires; @@ -209,9 +214,18 @@ get_int(const Header header, rpmTag tag) return rpmtdGetNumber(&val); } -static size_t +static uint64_t +get_int2(const Header header, rpmTag newtag, rpmTag oldtag) { + struct rpmtd_s val; + + if (!headerGet(header, newtag, &val, HEADERGET_DEFAULT)) + headerGet(header, oldtag, &val, HEADERGET_DEFAULT); + return rpmtdGetNumber(&val); +} + +static uint64_t get_filesize(const Header h) { - return headerGetNumber(h, RPMTAG_SIGSIZE) + 440; /* 440 is the rpm header size (?) empirical, but works */ + return get_int2(h, RPMTAG_LONGSIGSIZE, RPMTAG_SIGSIZE) + 440; /* 440 is the rpm header size (?) empirical, but works */ } static int @@ -758,7 +772,7 @@ pack_header(const URPM__Package pkg) { const char *nvr = headerGetAsString(pkg->h, RPMTAG_NVR); const char *arch = get_arch(pkg->h); p += 1 + snprintf(buff, sizeof(buff), "%s.%s@%llu@%llu@%s", nvr, arch, - get_int(pkg->h, RPMTAG_EPOCH), get_int(pkg->h, RPMTAG_SIZE), + (long long unsigned int) get_int(pkg->h, RPMTAG_EPOCH), (long long unsigned int) get_int2(pkg->h, RPMTAG_LONGSIZE, RPMTAG_SIZE), get_name(pkg->h, RPMTAG_GROUP)); pkg->info = memcpy(malloc(p-buff), buff, p-buff); } @@ -1047,7 +1061,7 @@ parse_line(AV *depslist, HV *provides, H // reset package, next line will be for another one memset(pkg, 0, sizeof(struct s_Package)); } else if (!strcmp(tag, "filesize")) - pkg->filesize = atoi(data); + pkg->filesize = atoll(data); else { char **ptr = NULL; if (!strcmp(tag, "requires")) @@ -1751,7 +1765,7 @@ Pkg_compare(pkg, evr) OUTPUT: RETVAL -int +uint64_t Pkg_size(pkg) URPM::Package pkg CODE: @@ -1761,12 +1775,12 @@ Pkg_size(pkg) if ((s = strchr(pkg->info, '@')) != NULL && (s = strchr(s+1, '@')) != NULL) { if ((eos = strchr(s+1, '@')) != NULL) *eos = 0; /* mark end of string to enable searching backwards */ - RETVAL = atoi(s+1); + RETVAL = atoll(s+1); if (eos != NULL) *eos = '@'; } else RETVAL = 0; } else if (pkg->h) - RETVAL = get_int(pkg->h, RPMTAG_SIZE); + RETVAL = get_int2(pkg->h, RPMTAG_LONGSIZE, RPMTAG_SIZE); else RETVAL = 0; OUTPUT: @@ -1775,11 +1789,11 @@ Pkg_size(pkg) void Pkg_set_filesize(pkg, filesize) URPM::Package pkg - size_t filesize; + uint64_t filesize; PPCODE: pkg->filesize = filesize; -int +uint64_t Pkg_filesize(pkg) URPM::Package pkg CODE: @@ -2087,7 +2101,7 @@ Pkg_build_info(pkg, fileno, provides_fil CODE: if (pkg->info) { char buff[65536*2]; - size_t size; + uint64_t size; /* info line should be the last to be written */ if (pkg->provides && *pkg->provides) { @@ -2121,7 +2135,7 @@ Pkg_build_info(pkg, fileno, provides_fil if (size < sizeof(buff)) write_nocheck(fileno, buff, size); } if (pkg->filesize) { - size = snprintf(buff, sizeof(buff), "@filesize@%d\n", pkg->filesize); + size = snprintf(buff, sizeof(buff), "@filesize@%llu\n", (long long unsigned int) pkg->filesize); if (size < sizeof(buff)) write_nocheck(fileno, buff, size); } size = snprintf(buff, sizeof(buff), "@info@%s\n", pkg->info); @@ -2755,6 +2769,7 @@ MODULE = URPM PACKAGE = URPM BOOT: (void) read_config_files(0); + PERL_MATH_INT64_LOAD_OR_CROAK; void Urpm_bind_rpm_textdomain_codeset()
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 19571
:
8522
|
8523
|
8525
|
8528
|
8529
|
8530
|
8531
|
8537
|
8538
|
8539
|
8541
|
8542
|
8543
|
8547
|
8548
|
8549
|
8563
|
8564
|
8565
|
8566