Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-30802

dnsmasq SAST: Error: SNYK_CODE_WARNING (CWE-125): dnsmasq-2.85/src/cache.c:1730:17: error[cpp/NegativeIndex]: The value from sprintf, a standard library function that can return a negative value is used as an index.

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • rhel-10.0
    • rhel-9.3.0
    • dnsmasq
    • None
    • None
    • None
    • rhel-sst-cs-net-perf-services
    • ssg_core_services
    • None
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • None

      What were you trying to do that didn't work?

      Error: SNYK_CODE_WARNING (CWE-125):
      dnsmasq-2.85/src/cache.c:1730:17: error[cpp/NegativeIndex]: The value from sprintf, a standard library function that can return a negative value is used as an index. A negative array index can lead to reading or writing outside the bounds of the array. Ensure the value of the index used is within bounds before use.
      # 1728|                 {
      # 1729|                   int targetlen = cache->addr.srv.targetlen;
      # 1730|->                 ssize_t len = sprintf(a, ""%u %u %u "", cache->addr.srv.priority,
      # 1731|                                         cache->addr.srv.weight, cache->addr.srv.srvport);
      # 1732|   
      
      

      Please provide the package NVR for which bug is seen:

      dnsmasq-2.85-14.el9

      How reproducible:

      Steps to reproduce

      Expected results

      Used just during cache dump. Trivial format on preallocated buffer is unlikely to fail. Should be fixed, but not likely attack vector

      Actual results

              pemensik@redhat.com Petr Mensik
              pemensik@redhat.com Petr Mensik
              Petr Mensik Petr Mensik
              Petr Sklenar Petr Sklenar
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: