You need to sign in or sign up before continuing.
  1. 16 10月, 2017 1 次提交
    • L
      hyperv: Escape WQL queries · 5ae2d9c2
      Ladi Prosek 提交于
      The code was vulnerable to SQL injection. Likely not a security issue due to
      WMI SQL and other constraints but still lame. For example:
      
        virsh # dominfo \"
        error: failed to get domain '"'
        error: internal error: SOAP fault during enumeration: code 's:Sender', subcode
        'n:CannotProcessFilter', reason 'The data source could not process the filter.
        The filter might be missing or it might be invalid. Change the filter and try
        the request again.  ', detail 'The WS-Management service cannot process the
        request. The WQL query is invalid. '
      
      This commit fixes the Hyper-V driver by escaping all WMI SQL string parameters.
      
      The same command with the fix:
      
        virsh # dominfo \"
        error: failed to get domain '"'
        error: Domain not found: No domain with name "
      Signed-off-by: NLadi Prosek <lprosek@redhat.com>
      5ae2d9c2
  2. 29 8月, 2017 1 次提交
  3. 28 8月, 2017 1 次提交
  4. 27 7月, 2017 1 次提交
  5. 12 5月, 2017 1 次提交
  6. 27 3月, 2017 1 次提交
  7. 24 2月, 2017 1 次提交
  8. 25 3月, 2015 1 次提交
  9. 25 2月, 2015 1 次提交
    • M
      util: Introduce virBufferAddBuffer · 83c5467e
      Michal Privoznik 提交于
      This API joins the following two lines:
      
      char *s = virBufferContentAndReset(buf1);
      virBufferAdd(buf2, s, -1);
      
      into one:
      
      virBufferAddBuffer(buf2, buf1);
      
      With one exception: there's no re-indentation applied to @buf1.
      The idea is, that in general both can have different indentation
      (like the test I'm adding proves)
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      83c5467e
  10. 24 8月, 2014 1 次提交
  11. 03 7月, 2014 1 次提交
    • J
      Introduce virBufferCheckError · 058d89b9
      Ján Tomko 提交于
      Check if the buffer is in error state and report an error if it is.
      
      This replaces the pattern:
      if (virBufferError(buf)) {
          virReportOOMError();
          goto cleanup;
      }
      with:
      
      if (virBufferCheckError(buf) < 0)
          goto cleanup;
      
      Document typical buffer usage to favor this.
      Also remove the redundant FreeAndReset - if an error has
      been set via virBufferSetError, the content is already freed.
      058d89b9
  12. 15 10月, 2013 1 次提交
    • E
      maint: avoid 'const fooPtr' in several util files · 1b0bc416
      Eric Blake 提交于
      'const fooPtr' is the same as 'foo * const' (the pointer won't
      change, but it's contents can).  But in general, if an interface
      is trying to be const-correct, it should be using 'const foo *'
      (the pointer is to data that can't be changed).
      
      Fix up offenders in src/util outside of the virnet namespace.
      
      Also, make a few virSocketAddr functions const-correct, for easier
      conversions in future patches.
      
      * src/util/virbuffer.h (virBufferError, virBufferUse)
      (virBufferGetIndent): Use intended type.
      * src/util/virmacaddr.h (virMacAddrCmp, virMacAddrCmpRaw)
      (virMacAddrSet, virMcAddrFormat, virMacAddrIsUnicast)
      (virMacAddrIsMulticast): Likewise.
      * src/util/virebtables.h (ebtablesAddForwardAllowIn)
      (ebtablesRemoveForwardAllowIn): Likewise.
      * src/util/virsocketaddr.h (virSocketAddrSetIPv4Addr): Drop
      incorrect const.
      (virMacAddrGetRaw, virSocketAddrFormat, virSocketAddrFormatFull):
      Make const-correct.
      (virSocketAddrMask, virSocketAddrMaskByPrefix)
      (virSocketAddrBroadcast, virSocketAddrBroadcastByPrefix)
      (virSocketAddrGetNumNetmaskBits, virSocketAddrGetIpPrefix)
      (virSocketAddrEqual, virSocketAddrIsPrivate)
      (virSocketAddrIsWildcard): Use intended type.
      * src/util/virbuffer.c (virBufferError, virBufferUse)
      (virBufferGetIndent): Fix fallout.
      * src/util/virmacaddr.c (virMacAddrCmp, virMacAddrCmpRaw)
      (virMacAddrSet, virMcAddrFormat, virMacAddrIsUnicast)
      (virMacAddrIsMulticast): Likewise.
      * src/util/virebtables.c (ebtablesAddForwardAllowIn)
      (ebtablesRemoveForwardAllowIn): Likewise.
      * src/util/virsocketaddr.c (virSocketAddrMask, virMacAddrGetRaw)
      (virSocketAddrMaskByPrefix, virSocketAddrBroadcast)
      (virSocketAddrBroadcastByPrefix, virSocketAddrGetNumNetmaskBits)
      (virSocketAddrGetIpPrefix, virSocketAddrEqual)
      (virSocketAddrIsPrivate, virSocketAddrIsWildcard)
      (virSocketAddrGetIPv4Addr, virSocketAddrGetIPv6Addr)
      (virSocketAddrFormat, virSocketAddrFormatFull): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1b0bc416
  13. 19 6月, 2013 1 次提交
    • J
      util: switch virBufferTrim to void · d0d0413e
      Ján Tomko 提交于
      We don't care whether the trim was succesful or not anywhere
      except the tests.
      
      Switch it to void and set the buffer error on wrong usage.
      d0d0413e
  14. 21 12月, 2012 1 次提交
  15. 21 9月, 2012 1 次提交
  16. 27 7月, 2012 1 次提交
    • O
      maint: Use consistent copyright. · a4bcefbc
      Osier Yang 提交于
      This is a follow up patch of commit f9ce7dad, it modifies all
      the files which declare the copyright like "See COPYING.LIB for
      the License of this software" to use the detailed/consistent one.
      
      And deserts the outdated comments like:
      
       * libvirt-qemu.h:
       * Summary: qemu specific interfaces
       * Description: Provides the interfaces of the libvirt library to handle
       *              qemu specific methods
       *
       * Copy:  Copyright (C) 2010, 2012 Red Hat, Inc.
      
      Uses the more compact style like:
      
       * libvirt-qemu.h: Interfaces specific for QEMU/KVM driver
       *
       * Copyright (C) 2010, 2012 Red Hat, Inc.
      a4bcefbc
  17. 11 6月, 2012 1 次提交
    • E
      buf: support peeking at string contents · 9202f2c2
      Eric Blake 提交于
      Right now, the only way to get at the contents of a virBuffer is
      to destroy it.  But there are cases in my upcoming patches where
      peeking at the contents makes life easier.  I suppose this does
      open up the potential for bad code to dereference a stale pointer,
      by disregarding the docs that the return value is invalid on the
      next virBuf operation, but such is life.
      
      * src/util/buf.h (virBufferCurrentContent): New declaration.
      * src/util/buf.c (virBufferCurrentContent): Implement it.
      * src/libvirt_private.syms (buf.h): Export it.
      * tests/virbuftest.c (testBufAutoIndent): Test it.
      9202f2c2
  18. 22 5月, 2012 1 次提交
    • E
      virBuffer: add way to trim back extra text · cdb87b1c
      Eric Blake 提交于
      I'm tired of writing:
      
      bool sep = false;
      while (...) {
          if (sep)
             virBufferAddChar(buf, ',');
          sep = true;
          virBufferAdd(buf, str);
      }
      
      This makes it easier, allowing one to write:
      
      while (...)
          virBufferAsprintf(buf, "%s,", str);
      virBufferTrim(buf, ",", -1);
      
      to trim any remaining comma.
      
      * src/util/buf.h (virBufferTrim): Declare.
      * src/util/buf.c (virBufferTrim): New function.
      * tests/virbuftest.c (testBufTrim): Test it.
      cdb87b1c
  19. 30 3月, 2012 1 次提交
  20. 12 3月, 2012 1 次提交
    • E
      qemu: support disk filenames with comma · 6e0ff1d4
      Eric Blake 提交于
      If there is a disk file with a comma in the name, QEmu expects a double
      comma instead of a single one (e.g., the file "virtual,disk.img" needs
      to be specified as "virtual,,disk.img" in QEmu's command line). This
      patch fixes libvirt to work with that feature. Fix RHBZ #801036.
      
      Based on an initial patch by Crístian Viana.
      
      * src/util/buf.h (virBufferEscape): Alter signature.
      * src/util/buf.c (virBufferEscape): Add parameter.
      (virBufferEscapeSexpr): Fix caller.
      * src/qemu/qemu_command.c (qemuBuildRBDString): Likewise.  Also
      escape commas in file names.
      (qemuBuildDriveStr): Escape commas in file names.
      * docs/schemas/basictypes.rng (absFilePath): Relax RNG to allow
      commas in input file names.
      * tests/qemuxml2argvdata/*-disk-drive-network-sheepdog.*: Update
      test.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      6e0ff1d4
  21. 21 10月, 2011 2 次提交
    • E
      virbuf: add auto-indentation support · fd9c052e
      Eric Blake 提交于
      Rather than having to adjust all callers in a chain to deal with
      indentation, it is nicer to have virBuffer do auto-indentation.
      
      * src/util/buf.h (_virBuffer): Increase size.
      (virBufferAdjustIndent, virBufferGetIndent): New prototypes.
      * src/libvirt_private.syms (buf.h): Export new functions.
      * src/util/buf.c (virBufferAdjustIndent, virBufferGetIndent): New
      functions.
      (virBufferSetError, virBufferAdd, virBufferAddChar)
      (virBufferVasprintf, virBufferStrcat, virBufferURIEncodeString):
      Implement auto-indentation.
      * tests/virbuftest.c (testBufAutoIndent): Test it.
      (testBufInfiniteLoop): Don't rely on internals.
      Idea by Daniel P. Berrange.
      fd9c052e
    • E
      virbuf: fix const-correctness · 5c09b81b
      Eric Blake 提交于
      Although the compiler wasn't complaining (since it was the pointer,
      rather than what was being pointed to, that was actually const), it
      looks quite suspicious to call a function with an argument labeled
      const when the nature of the pointer (virBufferPtr) is hidden behind
      a typedef.  Dropping const makes the function declarations easier
      to read.
      
      * src/util/buf.h: Drop const from all functions that modify buffer
      argument.
      * src/util/buf.c (virBufferSetError, virBufferAdd)
      (virBufferContentAndReset, virBufferFreeAndReset)
      (virBufferAsprintf, virBufferVasprintf, virBufferEscapeString)
      (virBufferEscapeSexpr, virBufferEscape): Fix fallout.
      5c09b81b
  22. 14 10月, 2011 1 次提交
  23. 13 10月, 2011 1 次提交
  24. 06 5月, 2011 2 次提交
    • E
      buf: add virBufferVasprintf · f09acccf
      Eric Blake 提交于
      Match the fact that we have virAsprintf and virVasprintf.
      
      * src/util/buf.h (virBufferVasprintf): New prototype.
      * src/util/buf.c (virBufferAsprintf): Move guts...
      (virBufferVasprintf): ...to new function.
      * src/libvirt_private.syms (buf.h): Export it.
      * bootstrap.conf (gnulib_modules): Add stdarg, for va_copy.
      f09acccf
    • E
      maint: rename virBufferVSprintf to virBufferAsprintf · 68ea80cf
      Eric Blake 提交于
      We already have virAsprintf, so picking a similar name helps for
      seeing a similar purpose.  Furthermore, the prefix V before printf
      generally implies 'va_list', even though this variant was '...', and
      the old name got in the way of adding a new va_list version.
      
      global rename performed with:
      
      $ git grep -l virBufferVSprintf \
        | xargs -L1 sed -i 's/virBufferVSprintf/virBufferAsprintf/g'
      
      then revert the changes in ChangeLog-old.
      68ea80cf
  25. 23 11月, 2010 1 次提交
  26. 10 3月, 2010 1 次提交
  27. 10 12月, 2009 1 次提交
    • M
      Add virBufferFreeAndReset() and replace free() · 1b9d0744
      Matthias Bolte 提交于
      Replace free(virBufferContentAndReset()) with virBufferFreeAndReset().
      Update documentation and replace all remaining calls to free() with
      calls to VIR_FREE(). Also add missing calls to virBufferFreeAndReset()
      and virReportOOMError() in OOM error cases.
      1b9d0744
  28. 06 11月, 2009 1 次提交
    • P
      Add sentinel attribute for NULL terminated arg lists · 649bcd72
      Paolo Bonzini 提交于
      * src/internal.h (ATTRIBUTE_SENTINEL): New, it's a ggc feature and
        protected as such
      * src/util/buf.c (virBufferStrcat): Use it.
      * src/util/ebtables.c (ebtablesAddRemoveRule): Use it.
      * src/util/iptables.c (iptableAddRemoveRule: Use it.
      * src/util/qparams.h (new_qparam_set, append_qparams): Use it.
      * docs/apibuild.py: avoid breaking the API generator with that new
        internal keyword macro
      649bcd72
  29. 21 9月, 2009 1 次提交
    • D
      Move all shared utility files to src/util/ · 1355e055
      Daniel P. Berrange 提交于
      * src/bridge.c, src/bridge.h, src/buf.c, src/buf.h, src/cgroup.c,
        src/cgroup.h, src/conf.c, src/conf.h, src/event.c, src/event.h,
        src/hash.c, src/hash.h, src/hostusb.c, src/hostusb.h,
        src/iptables.c, src/iptables.h, src/logging.c, src/logging.h,
        src/memory.c, src/memory.h, src/pci.c, src/pci.h, src/qparams.c,
        src/qparams.h, src/stats_linux.c, src/stats_linux.h,
        src/threads-pthread.c, src/threads-pthread.h, src/threads-win32.c,
        src/threads-win32.h, src/threads.c, src/threads.h, src/util.c,
        src/util.h, src/uuid.c, src/uuid.h, src/virterror.c,
        src/virterror_internal.h, src/xml.c, src/xml.h: Move all files
        into src/util/
      * daemon/Makefile.am: Add -Isrc/util/ to build flags
      * src/Makefile.am: Add -Isrc/util/ to build flags and update for
        moved files
      * src/libvirt_private.syms: Export cgroup APIs since they're now
        in util rather than linking directly to drivers
      * src/xen/xs_internal.c: Disable bogus virEventRemoveHandle call
        when built under PROXY
      * proxy/Makefile.am: Update for changed file locations. Remove
        bogus build of event.c
      * tools/Makefile.am, tests/Makefile.am: Add -Isrc/util/ to build flags
      1355e055
  30. 23 7月, 2009 1 次提交
    • D
      Fix misc Win32 compile warnings · 899ae0d2
      Daniel P. Berrange 提交于
      GCC >= 4.4 assumes the 'printf' attribute refers to the native
      runtime libraries format specifiers. Thanks to gnulib, libvirt
      has GNU format specifiers everywhere.  This means we need to
      use 'gnu_printf' with GCC >= 4.4 to get correct compiler
      checking of printf format specifiers.
      
      * HACKING: Document new rules for ATTRIBUTE_FMT_PRINTF
      * autobuild.sh, mingw32-libvirt.spec.in: Disable OpenNebula
        driver on mingw32 builds
      * qemud/dispatch.h, qemud/qemu.h, src/buf.h src/internal.h,
        src/logging.h, src/security.h, src/sexpr.h, src/util.h,
        src/virterror_internal.h, src/xend_internal.c: Change
        over to ATTRIBUTE_FMT_PRINTF.
      * src/virsh.c: Disable 'cd' and 'pwd' commands on Win32
        since they don't compile
      * src/threads-win32.c: Add missing return value check
      899ae0d2
  31. 17 11月, 2008 1 次提交
  32. 28 4月, 2008 1 次提交
  33. 20 2月, 2008 1 次提交
  34. 05 2月, 2008 1 次提交
    • J
      Eliminate all uses of virBufferAdd with string literals. · fb66d5ab
      Jim Meyering 提交于
      * Makefile.maint (sc_prohibit_virBufferAdd_with_string_literal):
      New rule.
      * src/buf.h (virBufferAddLit): Define.
      * src/conf.c (virConfSaveValue): Use virBufferAddLit, in place
      of virBufferAdd everywhere possible.
      (virConfSaveEntry): Likewise.
      * src/qemu_conf.c (qemudGenerateXML, qemudGenerateNetworkXML): Likewise.
      * src/qemu_driver.c (qemudGetFeatures, qemudGetCapabilities): Likewise.
      * src/test.c (testDomainDumpXML, testNetworkDumpXML): Likewise.
      * src/xen_internal.c (xenHypervisorMakeCapabilitiesXML): Likewise.
      * src/xend_internal.c (xend_parse_sexp_desc_os): Likewise.
      (xend_parse_sexp_desc, sexpr_to_xend_topology_xml): Likewise.
      * src/xm_internal.c (xenXMDomainFormatXML, xenXMDomainPinVcpu): Likewise.
      * src/xml.c (virSaveCpuSet, virParseXenCpuTopology): Likewise.
      (virDomainParseXMLGraphicsDescImage): Likewise.
      (virDomainParseXMLGraphicsDescVFB, virDomainParseXMLOSDescHVM): Likewise.
      (virDomainParseXMLOSDescPV, virDomainParseXMLDiskDesc): Likewise.
      (virDomainParseXMLIfDesc, virDomainParseXMLDesc): Likewise.
      fb66d5ab
  35. 17 12月, 2007 1 次提交
  36. 09 7月, 2007 1 次提交
  37. 27 6月, 2007 2 次提交