]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
repo parsers: use strtoull instead of atoi to parse the time
authorMichael Schroeder <mls@suse.de>
Tue, 3 Jun 2025 09:47:54 +0000 (11:47 +0200)
committerMichael Schroeder <mls@suse.de>
Tue, 3 Jun 2025 10:45:32 +0000 (12:45 +0200)
ext/repo_repomdxml.c
ext/repo_rpmmd.c
ext/repo_susetags.c
ext/repo_testcase.c

index 46d83615b64023fd29e47eb630cea677dca3f7a2..387759e0067fba5fd0058738500b8048d773f271 100644 (file)
@@ -77,6 +77,9 @@ support also extension suseinfo format
   <kewwords>
     <k>...</k>
   </keywords>
+  <tags>
+    <updates cpeid="cpe://o:opensuse_project:opensuse:11">openSUSE 11.0</updates>
+  </tags>
 </suseinfo>
 
 */
@@ -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;
       }
index 5d0f5fe7deab3bc61e97031ae92b1d832b5763cb..e7478936a01e76e93aeccfc8e73b2133ef989d28 100644 (file)
@@ -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;
       }
index 544974be5cc7747065cee172dc03ff4eebe1c334..77e4a57eacbb7a9fcb7e82d153f64f562bca65ff 100644 (file)
@@ -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);
              }
index e87938a151e51e6ba37ff3895e8c14c6c46bc4c5..0241e2a8094748f179d455baa4a924a6223a7c8f 100644 (file)
@@ -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);