Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-7013

non-standard strndup is used in dbupgrade.c file, DBpatch_2010101 function

    Details

    • Type: Incident report
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.4
    • Fix Version/s: 2.2.0
    • Component/s: Server (S)
    • Labels:
      None
    • Environment:
      Solaris x86, Sun Studio 12

      Description

      The strndup function is used in src/libs/zbxdbupgrade/dbupgrade.c in DBpatch_2010101 function. It is GNU function, not standard, so can't compile server and link zabbix server with SunStudio CC and guess same for other compilers except gcc.

      I fix it by the following code. but couldn't be a good choice.

      #Fix strndup issue on dbuphgrade.c
      STRNDUP_FUNC="//#if defined(SOLARIS)||defined(_APPLE) || defined(WIN32) || defined(_FORTEC)
      #define min(a,b) (a>b?b:a)
      char *strndup( const char *s, size_t n )

      { size_t nAvail; char *p; if ( !s ) return 0; nAvail = min( strlen(s) + 1, n + 1 ); p = malloc( nAvail ); memcpy( p, s, nAvail ); p[nAvail - 1] = '\0'; /* printf( \"[PAH][%s][%d] nAvail=%d p=(%s)\n\", __FILE__, __LINE__, nAvail, p ); */ return p; }

      "

      echo "$STRNDUP_FUNC" >> src/libs/zbxdbupgrade/dbupgrade.c

      sed '/static void parse_db_monitor_item_params.*/ i\
      char *strndup( const char *s, size_t n );\
      ' src/libs/zbxdbupgrade/dbupgrade.c > src/libs/zbxdbupgrade/dbupgrade.c.new && mv src/libs/zbxdbupgrade/dbupgrade.c.new src/libs/zbxdbupgrade/dbupgrade.c

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              omid.mt Omid Mehdizadeh
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: