Просмотр исходного кода

Handle server name overflow properly

We need to make sure it is null terminated on truncation. We also
need to avoid giving a too large size argument or modern gcc will
complain.
tags/v1.9.90
Pierre Ossman 5 лет назад
Родитель
Сommit
7240f62ddc
1 измененных файлов: 6 добавлений и 3 удалений
  1. 6
    3
      vncviewer/vncviewer.cxx

+ 6
- 3
vncviewer/vncviewer.cxx Просмотреть файл

newServerName = loadViewerParameters(vncServerName); newServerName = loadViewerParameters(vncServerName);
// This might be empty, but we still need to clear it so we // This might be empty, but we still need to clear it so we
// don't try to connect to the filename // don't try to connect to the filename
strncpy(vncServerName, newServerName, VNCSERVERNAMELEN);
strncpy(vncServerName, newServerName, VNCSERVERNAMELEN-1);
vncServerName[VNCSERVERNAMELEN-1] = '\0';
} catch (rfb::Exception& e) { } catch (rfb::Exception& e) {
vlog.error("%s", e.str()); vlog.error("%s", e.str());
if (alertOnFatalError) if (alertOnFatalError)
try { try {
const char* configServerName; const char* configServerName;
configServerName = loadViewerParameters(NULL); configServerName = loadViewerParameters(NULL);
if (configServerName != NULL)
strncpy(defaultServerName, configServerName, VNCSERVERNAMELEN);
if (configServerName != NULL) {
strncpy(defaultServerName, configServerName, VNCSERVERNAMELEN-1);
defaultServerName[VNCSERVERNAMELEN-1] = '\0';
}
} catch (rfb::Exception& e) { } catch (rfb::Exception& e) {
vlog.error("%s", e.str()); vlog.error("%s", e.str());
if (alertOnFatalError) if (alertOnFatalError)

Загрузка…
Отмена
Сохранить