nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info) { if (info.fName) PL_strfree(info.fName); if (info.fDescription) PL_strfree(info.fDescription); if (info.fMimeTypeArray) FreeStringArray(info.fVariantCount, info.fMimeTypeArray); if (info.fMimeDescriptionArray) FreeStringArray(info.fVariantCount, info.fMimeDescriptionArray); if (info.fExtensionArray) FreeStringArray(info.fVariantCount, info.fExtensionArray); if (info.fFullPath) PL_strfree(info.fFullPath); if (info.fFileName) PL_strfree(info.fFileName); if (info.fVersion) PR_smprintf_free(info.fVersion); ZeroMemory((void *)&info, sizeof(info)); return NS_OK; }
nsresult nsPluginFile::FreePluginInfo(nsPluginInfo& info) { if(info.fName != nsnull) PL_strfree(info.fName); if(info.fFullPath != nsnull) PL_strfree(info.fFullPath); if(info.fFileName != nsnull) PL_strfree(info.fFileName); if(info.fVersion != nsnull) PL_strfree(info.fVersion); if(info.fDescription != nsnull) PL_strfree(info.fDescription); if(info.fMimeTypeArray != nsnull) FreeStringArray(info.fVariantCount, info.fMimeTypeArray); if(info.fMimeDescriptionArray != nsnull) FreeStringArray(info.fVariantCount, info.fMimeDescriptionArray); if(info.fExtensionArray != nsnull) FreeStringArray(info.fVariantCount, info.fExtensionArray); memset((void *)&info, 0, sizeof(info)); return NS_OK; }
static DWORD DumpShareInfo( PSHARE_INFO_502 pShareInfo ) { DWORD dwError = 0; DWORD dwAllowUserCount = 0; PWSTR* ppwszAllowUsers = NULL; DWORD dwDenyUserCount = 0; PWSTR* ppwszDenyUsers = NULL; BOOLEAN bReadOnly = FALSE; PSTR pszUserName = NULL; DWORD dwIndex = 0; dwError = PrintStringAttribute("name", pShareInfo->shi502_netname); BAIL_ON_SRVSVC_ERROR(dwError); dwError = PrintStringAttribute("path", pShareInfo->shi502_path); BAIL_ON_SRVSVC_ERROR(dwError); dwError = PrintStringAttribute("comment", pShareInfo->shi502_remark); BAIL_ON_SRVSVC_ERROR(dwError); if (pShareInfo->shi502_security_descriptor) { dwError = DeconstructSecurityDescriptor( pShareInfo->shi502_reserved, (PSECURITY_DESCRIPTOR_RELATIVE) pShareInfo->shi502_security_descriptor, &dwAllowUserCount, &ppwszAllowUsers, &dwDenyUserCount, &ppwszDenyUsers, &bReadOnly); BAIL_ON_SRVSVC_ERROR(dwError); if (dwAllowUserCount) { printf("allow="); for (dwIndex = 0; dwIndex < dwAllowUserCount; dwIndex++) { dwError = LwWc16sToMbs(ppwszAllowUsers[dwIndex], &pszUserName); BAIL_ON_SRVSVC_ERROR(dwError); printf("%s", pszUserName); if (dwIndex < dwAllowUserCount - 1) { printf(","); } } printf("\n"); } if (dwDenyUserCount) { printf("deny="); for (dwIndex = 0; dwIndex < dwDenyUserCount; dwIndex++) { dwError = LwWc16sToMbs(ppwszDenyUsers[dwIndex], &pszUserName); BAIL_ON_SRVSVC_ERROR(dwError); printf("%s", pszUserName); if (dwIndex < dwDenyUserCount - 1) { printf(","); } } printf("\n"); } printf("read_only=%s\n", bReadOnly ? "true" : "false"); } cleanup: FreeStringArray(dwAllowUserCount, ppwszAllowUsers); FreeStringArray(dwDenyUserCount, ppwszDenyUsers); return dwError; error: goto cleanup; }
static DWORD SetInfo( int argc, char** ppszArgv ) { static const DWORD dwLevel = 502; DWORD dwError = 0; SHARE_INFO_502 newShareInfo = {0}; PSHARE_INFO_502 pShareInfo = NULL; DWORD dwParmErr = 0; PSECURITY_DESCRIPTOR_RELATIVE pSecDesc = NULL; DWORD dwSecDescSize = 0; DWORD dwAllowUserCount = 0; PWSTR* ppwszAllowUsers = NULL; DWORD dwDenyUserCount = 0; PWSTR* ppwszDenyUsers = NULL; BOOLEAN bReadOnly = FALSE; dwError = ParseShareArgs( argc, ppszArgv); BAIL_ON_SRVSVC_ERROR(dwError); dwError = NetShareGetInfo( gState.pwszServerName, gState.pwszTarget, dwLevel, OUT_PPVOID(&pShareInfo)); BAIL_ON_SRVSVC_ERROR(dwError); dwError = DeconstructSecurityDescriptor( pShareInfo->shi502_reserved, (PSECURITY_DESCRIPTOR_RELATIVE) pShareInfo->shi502_security_descriptor, &dwAllowUserCount, &ppwszAllowUsers, &dwDenyUserCount, &ppwszDenyUsers, &bReadOnly); BAIL_ON_SRVSVC_ERROR(dwError); newShareInfo = *pShareInfo; if (gState.pwszName) { newShareInfo.shi502_netname = gState.pwszName; } if (gState.pwszComment) { newShareInfo.shi502_remark = gState.pwszComment; } if (gState.pwszPath) { newShareInfo.shi502_path = gState.pwszPath; } dwError = ConstructSecurityDescriptor( gState.dwAllowUserCount || gState.bClearAllow ? gState.dwAllowUserCount : dwAllowUserCount, gState.dwAllowUserCount || gState.bClearAllow ? gState.ppwszAllowUsers : ppwszAllowUsers, gState.dwDenyUserCount || gState.bClearDeny ? gState.dwDenyUserCount : dwDenyUserCount, gState.dwDenyUserCount || gState.bClearDeny ? gState.ppwszDenyUsers : ppwszDenyUsers, gState.bReadOnly || gState.bReadWrite ? (gState.bReadOnly && !gState.bReadWrite) : bReadOnly, &pSecDesc, &dwSecDescSize); BAIL_ON_SRVSVC_ERROR(dwError); newShareInfo.shi502_type = pShareInfo->shi502_type; newShareInfo.shi502_reserved = dwSecDescSize; newShareInfo.shi502_security_descriptor = (PBYTE) pSecDesc; dwError = NetShareSetInfo( gState.pwszServerName, gState.pwszTarget, dwLevel, &newShareInfo, &dwParmErr); BAIL_ON_SRVSVC_ERROR(dwError); cleanup: if (pShareInfo) { SrvSvcFreeMemory(pShareInfo); } FreeStringArray(dwAllowUserCount, ppwszAllowUsers); FreeStringArray(dwDenyUserCount, ppwszDenyUsers); LW_SAFE_FREE_MEMORY(pSecDesc); return dwError; error: goto cleanup; }