Index: xbmc/lib/libGoAhead/WebServer.cpp =================================================================== --- xbmc/lib/libGoAhead/WebServer.cpp (revision 19120) +++ xbmc/lib/libGoAhead/WebServer.cpp (working copy) @@ -73,7 +73,10 @@ m_pXbmcHttp = new CXbmcHttp(); m_port = 80; /* Server port */ m_szPassword[0] = '\0'; - strcpy(m_szUserName,"xbmc"); + int end = sizeof(m_szUserName); + strncpy(m_szUserName,"xbmc",end); + if (end) + m_szUserName[end-1] = '\0'; m_hEvent = CreateEvent(NULL, true, false, NULL); } @@ -122,10 +125,15 @@ m_bStarted = false; ResetEvent(m_hEvent); - strcpy(m_szLocalAddress, szLocalAddress); - strcpy(m_szRootWeb, _P(web)); + int end = sizeof(m_szLocalAddress); + strncpy(m_szLocalAddress, szLocalAddress, end); + if (end) + m_szLocalAddress[end - 1] = '\0'; + end = sizeof(m_szRootWeb); + strncpy(m_szRootWeb, _P(web), end); + if (end) + m_szRootWeb[end - 1] = '\0'; m_port = port; - Create(false, THREAD_MINSTACKSIZE); if (m_ThreadHandle == NULL) return false; @@ -344,7 +352,13 @@ dbZero(did); // save password in member var for later usage by GetPassword() - if (strPassword) strcpy(m_szPassword, strPassword); + if (strPassword) + { + int end = sizeof(m_szPassword); + strncpy(m_szPassword, strPassword, end); + if (end) + m_szPassword[end - 1] = '\0'; + } // if password !NULL and greater then 0, enable user access if (strPassword && strlen(strPassword) > 0) @@ -374,7 +388,10 @@ if (strUserName && strlen(strUserName) > 0) { // save username in member var for later usage by GetPassword() - strcpy(m_szUserName, strUserName); + int end = sizeof(m_szUserName); + strncpy(m_szUserName, strUserName, end); + if (end) + m_szUserName[end - 1] = '\0'; if (m_szPassword && m_szPassword[0] != '\0') SetPassword(m_szPassword); } @@ -428,8 +445,11 @@ }; // check if one of the above files exist, if one does then redirect to it. - strcpy(dir, websGetDefaultDir()); - strcat(dir, path); + int size = sizeof(dir); + strncpy(dir, websGetDefaultDir(), size); + if (size) + dir[size-1] = '\0'; + strncat(dir, path, size - strlen(dir)); for(u_int pos = 0; pos < strlen(dir); pos++) if (dir[pos] == '/') dir[pos] = '\\'; @@ -438,17 +458,23 @@ { int i = 0; char buf[1024]; + size = sizeof(buf); while (files[i][0]) { - strcpy(buf, dir); - if (buf[strlen(buf)-1] != '\\') strcat(buf, "\\"); - strcat(buf, files[i]); + strncpy(buf, dir, size); + if (size) + buf[size-1] = '\0'; + if (buf[strlen(buf)-1] != '\\') + strncat(buf, "\\", size - strlen(buf)); + strncat(buf, files[i], size - strlen(buf)); if (!access(buf, 0)) { - strcpy(buf, path); - if (path[strlen(path)-1] != '/') strcat(buf, "/"); - strcat(buf, files[i]); + strncpy(buf, path, size); + if (size) + buf[size-1] = '\0'; + if (path[strlen(path)-1] != '/') strncat(buf, "/", size - strlen(buf)); + strncat(buf, files[i], size - strlen(buf)); websRedirect(wp, buf); return 1; } @@ -465,7 +491,7 @@ WIN32_FIND_DATA FindFileData; HANDLE hFind; vector vecFiles; - strcat(dir, "\\*"); + strncat(dir, "\\*", sizeof(dir) - strlen(dir)); hFind=FindFirstFile(dir, &FindFileData); do