diff options
Diffstat (limited to 'recipes-security/clamav/clamav-0.98.5/0009-fix-ssize_t-size_t-off_t-printf-modifier.patch')
-rw-r--r-- | recipes-security/clamav/clamav-0.98.5/0009-fix-ssize_t-size_t-off_t-printf-modifier.patch | 478 |
1 files changed, 0 insertions, 478 deletions
diff --git a/recipes-security/clamav/clamav-0.98.5/0009-fix-ssize_t-size_t-off_t-printf-modifier.patch b/recipes-security/clamav/clamav-0.98.5/0009-fix-ssize_t-size_t-off_t-printf-modifier.patch deleted file mode 100644 index ee60f92..0000000 --- a/recipes-security/clamav/clamav-0.98.5/0009-fix-ssize_t-size_t-off_t-printf-modifier.patch +++ /dev/null @@ -1,478 +0,0 @@ -From 26516ebe7ae678be78e748bc973835844e369f72 Mon Sep 17 00:00:00 2001 -From: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> -Date: Sun, 17 Aug 2014 21:24:03 +0200 -Subject: fix ssize_t/size_t/off_t printf modifier -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This fixes a segfault on ARM, Sparc, … if 64bit off_t is used. Once LFS -is enabled then off_t becomes 64bit and there is no portable way to express -it except to cast the variable to signed long long. However with LFS -enabled we can spare that cast. -The 32bit Architectures may explode here because the earlier 64bit off_t -consumes two argument slots and the filename (on which glibc uses -strlen()) becomes invalid. - -In brief: -ssize_t -> %zd -size_t -> %zu -off_t -> %llu (with LFS enabled) - -https://bugzilla.clamav.net/show_bug.cgi?id=11092 - -Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> ---- - clamd/clamd.c | 2 +- - clamd/server-th.c | 3 ++- - libclamav/adc.c | 5 +++-- - libclamav/asn1.c | 3 ++- - libclamav/bytecode.c | 4 ++-- - libclamav/bytecode_api.c | 2 +- - libclamav/hashtab.c | 32 +++++++++++++++++++++----------- - libclamav/jsparse/js-norm.c | 6 ++++-- - libclamav/matcher.c | 6 ++++-- - libclamav/pdf.c | 29 +++++++++++++++++++---------- - libclamav/regex_list.c | 5 ++++- - libclamav/scanners.c | 5 +++-- - shared/misc.h | 4 ++++ - shared/output.c | 3 ++- - sigtool/sigtool.c | 3 ++- - 15 files changed, 74 insertions(+), 38 deletions(-) - -diff --git a/clamd/clamd.c b/clamd/clamd.c -index ec15eacc8c25..8c87e1bb9a87 100644 ---- a/clamd/clamd.c -+++ b/clamd/clamd.c -@@ -355,7 +355,7 @@ int main(int argc, char **argv) - - - if(logg_size) -- logg("#Log file size limited to %u bytes.\n", logg_size); -+ logg("#Log file size limited to %" PRId64 "bytes.\n", logg_size); - else - logg("#Log file size limit disabled.\n"); - -diff --git a/clamd/server-th.c b/clamd/server-th.c -index 5c12811b662b..84086f39fbfb 100644 ---- a/clamd/server-th.c -+++ b/clamd/server-th.c -@@ -689,7 +689,8 @@ static int handle_stream(client_conn_t *conn, struct fd_buf *buf, const struct o - logg("!INSTREAM: Can't write to temporary file.\n"); - *error = 1; - } -- logg("$Processed %lu bytes of chunkdata, pos %lu\n", cmdlen, pos); -+ logg("$Processed %" _sizet " bytes of chunkdata, pos %" _sizet "\n", -+ cmdlen, pos); - pos += cmdlen; - if (pos == buf->off) { - buf->off = 0; -diff --git a/libclamav/adc.c b/libclamav/adc.c -index 6ad00ea96571..684335f1bfb5 100644 ---- a/libclamav/adc.c -+++ b/libclamav/adc.c -@@ -28,6 +28,7 @@ - #include <string.h> - #endif - -+#include "shared/misc.h" - #include "clamav.h" - #include "cltypes.h" - #include "others.h" -@@ -86,8 +87,8 @@ int adc_decompress(adc_stream *strm) - return ADC_DATA_ERROR; - } - -- cli_dbgmsg("adc_decompress: avail_in %lu avail_out %lu state %u\n", strm->avail_in, strm->avail_out, strm->state); -- -+ cli_dbgmsg("adc_decompress: avail_in %" _sizet " avail_out %" _sizet " state %u\n", -+ strm->avail_in, strm->avail_out, strm->state); - while (strm->avail_out) { - /* Exit if needs more in bytes and none available */ - int needsInput; -diff --git a/libclamav/asn1.c b/libclamav/asn1.c -index c6cf0dd00c50..e6f55642640d 100644 ---- a/libclamav/asn1.c -+++ b/libclamav/asn1.c -@@ -24,6 +24,7 @@ - - #include <time.h> - -+#include "shared/misc.h" - #include "clamav.h" - #include "asn1.h" - #include "bignum.h" -@@ -1481,7 +1482,7 @@ int asn1_check_mscat(struct cl_engine *engine, fmap_t *map, size_t offset, unsig - if (engine->dconf->pe & PE_CONF_DISABLECERT) - return CL_VIRUS; - -- cli_dbgmsg("in asn1_check_mscat (offset: %lu)\n", offset); -+ cli_dbgmsg("in asn1_check_mscat (offset: %" _sizet ")\n", offset); - crtmgr_init(&certs); - if(crtmgr_add_roots(engine, &certs)) { - crtmgr_free(&certs); -diff --git a/libclamav/bytecode.c b/libclamav/bytecode.c -index 28d2d716f93b..b34f818fdaba 100644 ---- a/libclamav/bytecode.c -+++ b/libclamav/bytecode.c -@@ -1489,8 +1489,8 @@ void cli_sigperf_print() - cli_infomsg (NULL, "%-*s %*s %*s %*s %*s\n", max_name_len, "=============", - 8, "=====", 8, "========", 12, "===========", 9, "========="); - while (elem->run_count) { -- cli_infomsg (NULL, "%-*s %*lu %*lu %*llu %*.2f\n", max_name_len, elem->bc_name, -- 8, elem->run_count, 8, elem->match_count, -+ cli_infomsg (NULL, "%-*s %*lu %*lu %*" PRIu64 " %*.2f\n", max_name_len, -+ elem->bc_name, 8, elem->run_count, 8, elem->match_count, - 12, elem->usecs, 9, (double)elem->usecs/elem->run_count); - elem++; - } -diff --git a/libclamav/bytecode_api.c b/libclamav/bytecode_api.c -index 5bded4ebaca0..72a9393183a2 100644 ---- a/libclamav/bytecode_api.c -+++ b/libclamav/bytecode_api.c -@@ -122,7 +122,7 @@ int32_t cli_bcapi_seek(struct cli_bc_ctx* ctx, int32_t pos, uint32_t whence) - return -1; - } - if (off < 0 || off > ctx->file_size) { -- cli_dbgmsg("bcapi_seek: out of file: %ld (max %d)\n", -+ cli_dbgmsg("bcapi_seek: out of file: %" PRId64 " (max %d)\n", - off, ctx->file_size); - return -1; - } -diff --git a/libclamav/hashtab.c b/libclamav/hashtab.c -index 88e81ba2c2ef..cafce3ac8927 100644 ---- a/libclamav/hashtab.c -+++ b/libclamav/hashtab.c -@@ -25,6 +25,7 @@ - #include <stdio.h> - #include <string.h> - -+#include "shared/misc.h" - #include "cltypes.h" - #include "clamav.h" - #include "others.h" -@@ -329,9 +330,10 @@ static int cli_hashtab_grow(struct cli_hashtable *s) - struct cli_element* htable; - size_t i,idx, used = 0; - -- cli_dbgmsg("hashtab.c: new capacity: %lu\n",new_capacity); -+ cli_dbgmsg("hashtab.c: new capacity: %" _sizet "\n",new_capacity); - if(new_capacity == s->capacity) { -- cli_errmsg("hashtab.c: capacity problem growing from: %lu\n",s->capacity); -+ cli_errmsg("hashtab.c: capacity problem growing from: %" _sizet -+ "\n", s->capacity); - return CL_EMEM; - } - htable = cli_calloc(new_capacity, sizeof(*s->htable)); -@@ -372,7 +374,7 @@ static int cli_hashtab_grow(struct cli_hashtable *s) - s->used = used; - s->capacity = new_capacity; - s->maxfill = new_capacity*8/10; -- cli_dbgmsg("Table %p size after grow:%ld\n",(void*)s,s->capacity); -+ cli_dbgmsg("Table %p size after grow: %" _sizet "\n", s, s->capacity); - PROFILE_GROW_DONE(s); - return CL_SUCCESS; - } -@@ -386,7 +388,7 @@ static int cli_htu32_grow(struct cli_htu32 *s, mpool_t *mempool) - const size_t new_capacity = nearest_power(s->capacity + 1); - struct cli_htu32_element* htable = mpool_calloc(mempool, new_capacity, sizeof(*s->htable)); - size_t i,idx, used = 0; -- cli_dbgmsg("hashtab.c: new capacity: %lu\n",new_capacity); -+ cli_dbgmsg("hashtab.c: new capacity: %" _sizet "\n", new_capacity); - if(new_capacity == s->capacity || !htable) - return CL_EMEM; - -@@ -422,7 +424,7 @@ static int cli_htu32_grow(struct cli_htu32 *s, mpool_t *mempool) - s->used = used; - s->capacity = new_capacity; - s->maxfill = new_capacity*8/10; -- cli_dbgmsg("Table %p size after grow:%ld\n",(void*)s,s->capacity); -+ cli_dbgmsg("Table %p size after grow: %" _sizet "\n", s, s->capacity); - PROFILE_GROW_DONE(s); - return CL_SUCCESS; - } -@@ -437,7 +439,9 @@ const struct cli_element* cli_hashtab_insert(struct cli_hashtable *s, const char - if(!s) - return NULL; - if(s->used > s->maxfill) { -- cli_dbgmsg("hashtab.c:Growing hashtable %p, because it has exceeded maxfill, old size:%ld\n",(void*)s,s->capacity); -+ cli_dbgmsg("hashtab.c:Growing hashtable %p, because it has " -+ "exceeded maxfill, old size: %" _sizet "\n", s, -+ s->capacity); - cli_hashtab_grow(s); - } - do { -@@ -486,7 +490,8 @@ const struct cli_element* cli_hashtab_insert(struct cli_hashtable *s, const char - } while (tries <= s->capacity); - /* no free place found*/ - PROFILE_HASH_EXHAUSTED(s); -- cli_dbgmsg("hashtab.c: Growing hashtable %p, because its full, old size:%ld.\n",(void*)s,s->capacity); -+ cli_dbgmsg("hashtab.c: Growing hashtable %p, because its full, " -+ "old size: %" _sizet ".\n", s, s->capacity); - } while( cli_hashtab_grow(s) >= 0 ); - cli_warnmsg("hashtab.c: Unable to grow hashtable\n"); - return NULL; -@@ -504,7 +509,9 @@ int cli_htu32_insert(struct cli_htu32 *s, const struct cli_htu32_element *item, - if(!s) - return CL_ENULLARG; - if(s->used > s->maxfill) { -- cli_dbgmsg("hashtab.c:Growing hashtable %p, because it has exceeded maxfill, old size:%ld\n",(void*)s,s->capacity); -+ cli_dbgmsg("hashtab.c:Growing hashtable %p, because it has " -+ "exceeded maxfill, old size: %" _sizet "\n", s, -+ s->capacity); - cli_htu32_grow(s, mempool); - } - do { -@@ -543,7 +550,8 @@ int cli_htu32_insert(struct cli_htu32 *s, const struct cli_htu32_element *item, - } while (tries <= s->capacity); - /* no free place found*/ - PROFILE_HASH_EXHAUSTED(s); -- cli_dbgmsg("hashtab.c: Growing hashtable %p, because its full, old size:%ld.\n",(void*)s,s->capacity); -+ cli_dbgmsg("hashtab.c: Growing hashtable %p, because its full, " -+ "old size: %" _sizet ".\n", s, s->capacity); - } while( (ret = cli_htu32_grow(s, mempool)) >= 0 ); - cli_warnmsg("hashtab.c: Unable to grow hashtable\n"); - return ret; -@@ -632,11 +640,13 @@ int cli_hashtab_generate_c(const struct cli_hashtable *s,const char* name) - else if(e->key == DELETED_KEY) - printf("\t{DELETED_KEY,0,0},\n"); - else -- printf("\t{\"%s\", %ld, %ld},\n", e->key, e->data, e->len); -+ printf("\t{\"%s\", %ld, %" _sizet"},\n", e->key, -+ e->data, e->len); - } - printf("};\n"); - printf("const struct cli_hashtable %s = {\n",name); -- printf("\t%s_elements, %ld, %ld, %ld", name, s->capacity, s->used, s->maxfill); -+ printf("\t%s_elements, %" _sizet ", %" _sizet" , %" _sizet, name, -+ s->capacity, s->used, s->maxfill); - printf("\n};\n"); - - PROFILE_REPORT(s); -diff --git a/libclamav/jsparse/js-norm.c b/libclamav/jsparse/js-norm.c -index 85eba72c2e87..9a56aa34856f 100644 ---- a/libclamav/jsparse/js-norm.c -+++ b/libclamav/jsparse/js-norm.c -@@ -34,6 +34,7 @@ - #include <ctype.h> - #include <assert.h> - -+#include "shared/misc.h" - #include "clamav.h" - #include "cltypes.h" - #include "jsparse/lexglobal.h" -@@ -525,7 +526,8 @@ static int replace_token_range(struct tokens *dst, size_t start, size_t end, con - { - const size_t len = with ? with->cnt : 0; - size_t i; -- cli_dbgmsg(MODULE "Replacing tokens %lu - %lu with %lu tokens\n",start, end, len); -+ cli_dbgmsg(MODULE "Replacing tokens %" _sizet " - %" _sizet " with %" -+ _sizet " tokens\n", start, end, len); - if(start >= dst->cnt || end > dst->cnt) - return -1; - for(i=start;i<end;i++) { -@@ -547,7 +549,7 @@ static int append_tokens(struct tokens *dst, const struct tokens *src) - return CL_ENULLARG; - if(tokens_ensure_capacity(dst, dst->cnt + src->cnt)) - return CL_EMEM; -- cli_dbgmsg(MODULE "Appending %lu tokens\n", src->cnt); -+ cli_dbgmsg(MODULE "Appending %" _sizet " tokens\n", src->cnt); - memcpy(&dst->data[dst->cnt], src->data, src->cnt * sizeof(dst->data[0])); - dst->cnt += src->cnt; - return CL_SUCCESS; -diff --git a/libclamav/matcher.c b/libclamav/matcher.c -index 3f4f5c1659d5..e684f7122e26 100644 ---- a/libclamav/matcher.c -+++ b/libclamav/matcher.c -@@ -52,6 +52,7 @@ - #include "perflogging.h" - #include "bytecode_priv.h" - #include "bytecode_api_impl.h" -+#include "shared/misc.h" - - #ifdef CLI_PERF_LOGGING - -@@ -1069,8 +1070,9 @@ int cli_matchmeta(cli_ctx *ctx, const char *fname, size_t fsizec, size_t fsizer, - const struct cli_cdb *cdb; - unsigned int viruses_found = 0; - -- cli_dbgmsg("CDBNAME:%s:%lu:%s:%lu:%lu:%d:%u:%u:%p\n", -- cli_ftname(ctx->container_type), fsizec, fname, fsizec, fsizer, encrypted, filepos, res1, res2); -+ cli_dbgmsg("CDBNAME:%s:%" _sizet ":%s:%" _sizet ":%" _sizet ":%d:%u:%u:%p\n", -+ cli_ftname(ctx->container_type), fsizec, fname, fsizec, fsizer, -+ encrypted, filepos, res1, res2); - - if (ctx->engine && ctx->engine->cb_meta) - if (ctx->engine->cb_meta(cli_ftname(ctx->container_type), fsizec, fname, fsizer, encrypted, filepos, ctx->cb_ctx) == CL_VIRUS) { -diff --git a/libclamav/pdf.c b/libclamav/pdf.c -index 2e469c1e5d56..2de348e7c3fd 100644 ---- a/libclamav/pdf.c -+++ b/libclamav/pdf.c -@@ -60,6 +60,7 @@ - #include "rijndael.h" - #include "textnorm.h" - #include "json_api.h" -+#include "shared/misc.h" - - #ifdef CL_DEBUG - /*#define SAVE_TMP -@@ -1019,10 +1020,12 @@ int pdf_extract_obj(struct pdf_struct *pdf, struct pdf_obj *obj, uint32_t flags) - - orig_length = length; - if (length > pdf->size || obj->start + p_stream + length > pdf->size) { -- cli_dbgmsg("cli_pdf: length out of file: %ld + %ld > %ld\n", -- p_stream, length, pdf->size); -- noisy_warnmsg("length out of file, truncated: %ld + %ld > %ld\n", -- p_stream, length, pdf->size); -+ cli_dbgmsg("cli_pdf: length out of file: %" PRId64 " + %" -+ PRId64 " > % " PRId64 "\n", p_stream, -+ length, pdf->size); -+ noisy_warnmsg("length out of file, truncated: %" PRId64 -+ " + %" PRId64 " > %" PRId64 "\n", -+ p_stream, length, pdf->size); - length = pdf->size - (obj->start + p_stream); - } - -@@ -1044,17 +1047,21 @@ int pdf_extract_obj(struct pdf_struct *pdf, struct pdf_obj *obj, uint32_t flags) - if (length < 0) - length = 0; - -- cli_dbgmsg("cli_pdf: calculated length %ld\n", length); -+ cli_dbgmsg("cli_pdf: calculated length %" PRId64 "\n", -+ length); - } else { - if (size > (size_t)length+2) { -- cli_dbgmsg("cli_pdf: calculated length %ld < %ld\n", -+ cli_dbgmsg("cli_pdf: calculated length %" PRId64 " < %" -+ _ssizet "\n", - length, size); - length = size; - } - } - - if (orig_length && size > (size_t)orig_length + 20) { -- cli_dbgmsg("cli_pdf: orig length: %ld, length: %ld, size: %ld\n", orig_length, length, size); -+ cli_dbgmsg("cli_pdf: orig length: %" PRId64 ", length: %" -+ PRId64", size: %" _ssizet "\n", orig_length, -+ length, size); - pdfobj_flag(pdf, obj, BAD_STREAMLEN); - } - -@@ -1240,7 +1247,7 @@ int pdf_extract_obj(struct pdf_struct *pdf, struct pdf_obj *obj, uint32_t flags) - } - } while (0); - -- cli_dbgmsg("cli_pdf: extracted %ld bytes %u %u obj to %s\n", sum, obj->id>>8, obj->id&0xff, fullname); -+ cli_dbgmsg("cli_pdf: extracted %" PRId64 " bytes %u %u obj to %p\n", sum, obj->id>>8, obj->id&0xff, fullname); - - if (flags & PDF_EXTRACT_OBJ_SCAN && sum) { - int rc2; -@@ -2493,7 +2500,8 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset) - - if (pdfver != start || offset) { - pdf.flags |= 1 << BAD_PDF_HEADERPOS; -- cli_dbgmsg("cli_pdf: PDF header is not at position 0: %ld\n",pdfver-start+offset); -+ cli_dbgmsg("cli_pdf: PDF header is not at position 0: %" PRId64 "\n", -+ pdfver - start + offset); - #if HAVE_JSON - if (pdfobj) - cli_jsonbool(pdfobj, "BadVersionLocation", 1); -@@ -2602,7 +2610,8 @@ int cli_pdf(const char *dir, cli_ctx *ctx, off_t offset) - while ((rc = pdf_findobj(&pdf)) > 0) { - struct pdf_obj *obj = &pdf.objs[pdf.nobjs-1]; - -- cli_dbgmsg("cli_pdf: found %d %d obj @%ld\n", obj->id >> 8, obj->id&0xff, obj->start + offset); -+ cli_dbgmsg("cli_pdf: found %d %d obj @%" PRId64 "\n", obj->id >> 8, -+ obj->id & 0xff, obj->start + offset); - } - - if (pdf.nobjs) -diff --git a/libclamav/regex_list.c b/libclamav/regex_list.c -index f30cc4cd4349..4b27c2974fb6 100644 ---- a/libclamav/regex_list.c -+++ b/libclamav/regex_list.c -@@ -41,6 +41,7 @@ - #include <assert.h> - - #include "regex/regex.h" -+#include "shared/misc.h" - - #include "clamav.h" - #include "others.h" -@@ -84,7 +85,9 @@ static inline size_t get_char_at_pos_with_skip(const struct pre_fixup_info* info - return (pos <= strlen(buffer)) ? buffer[pos>0 ? pos-1:0] : '\0'; - } - str = info->pre_displayLink.data; -- cli_dbgmsg("calc_pos_with_skip: skip:%lu, %lu - %lu \"%s\",\"%s\"\n", pos, info->host_start, info->host_end, str, buffer); -+ cli_dbgmsg("calc_pos_with_skip: skip: %" _sizet ", %" _sizet " - %" -+ _sizet " \"%s\",\"%s\"\n", pos, info->host_start, -+ info->host_end, str, buffer); - pos += info->host_start; - while(str[realpos] && !isalnum(str[realpos])) realpos++; - for(; str[realpos] && (pos>0); pos--) { -diff --git a/libclamav/scanners.c b/libclamav/scanners.c -index 07a38eedc7a5..49cd70a18d9e 100644 ---- a/libclamav/scanners.c -+++ b/libclamav/scanners.c -@@ -49,6 +49,7 @@ - #define DCONF_MAIL ctx->dconf->mail - #define DCONF_OTHER ctx->dconf->other - -+#include "shared/misc.h" - #include "clamav.h" - #include "others.h" - #include "dconf.h" -@@ -3171,8 +3172,8 @@ int cli_map_scandesc(cl_fmap_t *map, off_t offset, size_t length, cli_ctx *ctx, - - if (!length) length = old_len - offset; - if (length > old_len - offset) { -- cli_dbgmsg("Data truncated: %lu -> %lu\n", -- (unsigned long)length, old_len - offset); -+ cli_dbgmsg("Data truncated: %" _sizet" -> %" PRIu64" \n", length, -+ old_len - offset); - length = old_len - offset; - } - -diff --git a/shared/misc.h b/shared/misc.h -index 3e093936caa1..65f8c9ce0382 100644 ---- a/shared/misc.h -+++ b/shared/misc.h -@@ -51,6 +51,10 @@ - #define PATH_MAX 1024 - #endif - -+#include <inttypes.h> -+#define _sizet "zu" -+#define _ssizet "zd" -+ - char *freshdbdir(void); - void print_version(const char *dbdir); - int check_flevel(void); -diff --git a/shared/output.c b/shared/output.c -index 5e947a57a6f9..ab054a8bbeee 100644 ---- a/shared/output.c -+++ b/shared/output.c -@@ -214,7 +214,8 @@ static int rename_logg(STATBUF *sb) - - if (!logg_rotate) { - if (logg_fp) { -- fprintf(logg_fp, "Log size = %zu, max = %zu\n", sb->st_size, logg_size); -+ fprintf(logg_fp, "Log size = %" PRId64 ", max = %" PRId64 "\n", -+ sb->st_size, logg_size); - fprintf(logg_fp, "WARNING: Log size limit met but log file rotation turned off. Forcing log file rotation anyways.\n"); - } - -diff --git a/sigtool/sigtool.c b/sigtool/sigtool.c -index f2135c210e02..d67e662cfea1 100644 ---- a/sigtool/sigtool.c -+++ b/sigtool/sigtool.c -@@ -373,7 +373,8 @@ static char *getdsig(const char *host, const char *user, const unsigned char *da - closesocket(sockd); - return NULL; - } else { -- mprintf("Signature received (length = %lu)\n", (unsigned long)strlen(buff) - 10); -+ mprintf("Signature received (length = %" _sizet ")\n", -+ (unsigned long)strlen(buff) - 10); - } - } else { - mprintf("!getdsig: Communication error with remote server\n"); |