From 6eb8741bcc120ceb1cb2aebaaba8f00922d8d1e5 Mon Sep 17 00:00:00 2001 From: Michael Schroeder Date: Tue, 3 Jun 2025 11:47:54 +0200 Subject: [PATCH] repo parsers: use strtoull instead of atoi to parse the time --- ext/repo_repomdxml.c | 13 ++++++++----- ext/repo_rpmmd.c | 8 ++++---- ext/repo_susetags.c | 8 ++++---- ext/repo_testcase.c | 14 +++++++------- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/ext/repo_repomdxml.c b/ext/repo_repomdxml.c index 46d83615..387759e0 100644 --- a/ext/repo_repomdxml.c +++ b/ext/repo_repomdxml.c @@ -77,6 +77,9 @@ support also extension suseinfo format ... + + openSUSE 11.0 + */ @@ -147,7 +150,7 @@ struct parsedata { struct solv_xmlparser xmlp; - int timestamp; + unsigned int timestamp; /* handles for collection structures */ /* repo updates */ @@ -252,7 +255,7 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content) switch (state) { case STATE_REPOMD: - if (pd->timestamp > 0) + if (pd->timestamp) repodata_set_num(pd->data, SOLVID_META, REPOSITORY_TIMESTAMP, pd->timestamp); break; case STATE_DATA: @@ -278,7 +281,7 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content) * of all resources to save it as the time * the metadata was generated */ - int timestamp = atoi(content); + unsigned int timestamp = strtoull(content, 0, 10); if (timestamp) repodata_set_num(pd->data, pd->rdhandle, REPOSITORY_REPOMD_TIMESTAMP, timestamp); if (timestamp > pd->timestamp) @@ -287,8 +290,8 @@ endElement(struct solv_xmlparser *xmlp, int state, char *content) } case STATE_EXPIRE: { - int expire = atoi(content); - if (expire > 0) + unsigned int expire = strtoull(content, 0, 10); + if (expire) repodata_set_num(pd->data, SOLVID_META, REPOSITORY_EXPIRE, expire); break; } diff --git a/ext/repo_rpmmd.c b/ext/repo_rpmmd.c index 5d0f5fe7..e7478936 100644 --- a/ext/repo_rpmmd.c +++ b/ext/repo_rpmmd.c @@ -826,10 +826,10 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha break; case STATE_TIME: { - unsigned int t; + unsigned int ti; str = solv_xmlparser_find_attr("build", atts); - if (str && (t = atoi(str)) != 0) - repodata_set_num(pd->data, handle, SOLVABLE_BUILDTIME, t); + if (str && (ti = strtoull(str, 0, 10)) != 0) + repodata_set_num(pd->data, handle, SOLVABLE_BUILDTIME, ti); break; } case STATE_SIZE: @@ -842,7 +842,7 @@ startElement(struct solv_xmlparser *xmlp, int state, const char *name, const cha { unsigned int end; str = solv_xmlparser_find_attr("end", atts); - if (str && (end = atoi(str)) != 0) + if (str && (end = strtoull(str, 0, 10)) != 0) repodata_set_num(pd->data, handle, SOLVABLE_HEADEREND, end); break; } diff --git a/ext/repo_susetags.c b/ext/repo_susetags.c index 544974be..77e4a57e 100644 --- a/ext/repo_susetags.c +++ b/ext/repo_susetags.c @@ -925,9 +925,9 @@ repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int continue; case CTAG('=', 'T', 'i', 'm'): { - unsigned int t = atoi(line + 6); - if (t) - repodata_set_num(data, handle, SOLVABLE_BUILDTIME, t); + unsigned int ti = strtoull(line + 6, 0, 10); + if (ti) + repodata_set_num(data, handle, SOLVABLE_BUILDTIME, ti); } continue; case CTAG('=', 'K', 'w', 'd'): @@ -1052,7 +1052,7 @@ repo_add_susetags(Repo *repo, FILE *fp, Id defvendor, const char *language, int if (split(line + 6, sp, 3) == 2) { /* we ignore the start value */ - unsigned int end = (unsigned int)atoi(sp[1]); + unsigned int end = strtoull(sp[1], 0, 10); if (end) repodata_set_num(data, handle, SOLVABLE_HEADEREND, end); } diff --git a/ext/repo_testcase.c b/ext/repo_testcase.c index e87938a1..0241e2a8 100644 --- a/ext/repo_testcase.c +++ b/ext/repo_testcase.c @@ -545,7 +545,7 @@ testcase_add_testtags(Repo *repo, FILE *fp, int flags) Repodata *data; Solvable *s; char *sp[5]; - unsigned int t; + unsigned int ti; int intag; char *filelist = 0; int afilelist = 0; @@ -640,14 +640,14 @@ testcase_add_testtags(Repo *repo, FILE *fp, int flags) s->vendor = pool_str2id(pool, line + 6, 1); break; case 'T' << 16 | 'i' << 8 | 'm': - t = atoi(line + 6); - if (t) - repodata_set_num(data, s - pool->solvables, SOLVABLE_BUILDTIME, t); + ti = strtoull(line + 6, 0, 10); + if (ti) + repodata_set_num(data, s - pool->solvables, SOLVABLE_BUILDTIME, ti); break; case 'I' << 16 | 't' << 8 | 'm': - t = atoi(line + 6); - if (t) - repodata_set_num(data, s - pool->solvables, SOLVABLE_INSTALLTIME, t); + ti = strtoull(line + 6, 0, 10); + if (ti) + repodata_set_num(data, s - pool->solvables, SOLVABLE_INSTALLTIME, ti); break; case 'R' << 16 | 'e' << 8 | 'q': s->requires = adddep(repo, s->requires, line + 6, -SOLVABLE_PREREQMARKER); -- 2.47.2