Author: truckman Date: Fri Sep 2 07:14:17 2016 New Revision: 1758884 URL: http://svn.apache.org/viewvc?rev=1758884&view=rev Log: Fix improper usage of strncat() and snprintf(). Flagged by -Wstrncat-size compiler warning from clang.
Modified: openoffice/trunk/main/sal/osl/unx/pipe.c Modified: openoffice/trunk/main/sal/osl/unx/pipe.c URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sal/osl/unx/pipe.c?rev=1758884&r1=1758883&r2=1758884&view=diff ============================================================================== --- openoffice/trunk/main/sal/osl/unx/pipe.c (original) +++ openoffice/trunk/main/sal/osl/unx/pipe.c Fri Sep 2 07:14:17 2016 @@ -35,8 +35,8 @@ #define PIPEDEFAULTPATH "/tmp" #define PIPEALTERNATEPATH "/var/tmp" -#define PIPENAMEMASK "OSL_PIPE_%s" -#define SECPIPENAMEMASK "OSL_PIPE_%s_%s" +#define PIPENAMEMASK "%s/OSL_PIPE_%s" +#define SECPIPENAMEMASK "%s/OSL_PIPE_%s_%s" sal_Bool SAL_CALL osl_psz_getUserIdent(oslSecurity Security, sal_Char *pszIdent, sal_uInt32 nMax); oslPipe SAL_CALL osl_psz_createPipe(const sal_Char *pszPipeName, oslPipeOptions Options, oslSecurity Security); @@ -165,34 +165,32 @@ oslPipe SAL_CALL osl_psz_createPipe(cons size_t len; struct sockaddr_un addr; - sal_Char name[PATH_MAX + 1]; + sal_Char name[PATH_MAX + 1]; + const sal_Char *pPath; oslPipe pPipe; if (access(PIPEDEFAULTPATH, R_OK|W_OK) == 0) - { - strncpy(name, PIPEDEFAULTPATH, sizeof(name)); - } + { + pPath = PIPEDEFAULTPATH; + } else - { - strncpy(name, PIPEALTERNATEPATH, sizeof(name)); - } - - - strncat(name, "/", sizeof(name)); + { + pPath = PIPEALTERNATEPATH; + } if (Security) { sal_Char Ident[256]; - Ident[0] = '\0'; + Ident[0] = '\0'; OSL_VERIFY(osl_psz_getUserIdent(Security, Ident, sizeof(Ident))); - snprintf(&name[strlen(name)], sizeof(name), SECPIPENAMEMASK, Ident, pszPipeName); + snprintf(name, sizeof(name), SECPIPENAMEMASK, pPath, Ident, pszPipeName); } else { - snprintf(&name[strlen(name)], sizeof(name), PIPENAMEMASK, pszPipeName); + snprintf(name, sizeof(name), PIPENAMEMASK, pPath, pszPipeName); }