mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0022953: strcat expects null-terminated destination string
This commit is contained in:
parent
a0ed63ac93
commit
f78c0415f7
@ -7,8 +7,6 @@ OSD_Function.cxx
|
|||||||
OSD_Getkey.c
|
OSD_Getkey.c
|
||||||
OSD_Function.hxx
|
OSD_Function.hxx
|
||||||
OSD_ErrorList.hxx
|
OSD_ErrorList.hxx
|
||||||
ethernet.h-sgi
|
|
||||||
ethernet.h-dec
|
|
||||||
OSD_WNT.cxx
|
OSD_WNT.cxx
|
||||||
OSD_WNT_1.cxx
|
OSD_WNT_1.cxx
|
||||||
OSD_WNT.hxx
|
OSD_WNT.hxx
|
||||||
|
@ -41,10 +41,6 @@ raises ConstructionError, NullObject, OSDError
|
|||||||
---Purpose: Returns Internet address of current host.
|
---Purpose: Returns Internet address of current host.
|
||||||
---Level: Advanced
|
---Level: Advanced
|
||||||
|
|
||||||
EthernetAddress (me : in out) returns AsciiString is static;
|
|
||||||
---Purpose: Returns Ethernet address of current host.
|
|
||||||
---Level: Advanced
|
|
||||||
|
|
||||||
MachineType (me : in out) returns OEMType is static;
|
MachineType (me : in out) returns OEMType is static;
|
||||||
---Purpose: Returns type of current machine.
|
---Purpose: Returns type of current machine.
|
||||||
---Level: Advanced
|
---Level: Advanced
|
||||||
|
@ -165,34 +165,6 @@ TCollection_AsciiString OSD_Host::InternetAddress(){
|
|||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// =========================================================================
|
|
||||||
// Adresse ethernet: Disponible uniquement (et de facon fiable) sur ========
|
|
||||||
// DIGITAL (DEC OSF1) et SILICON (IRIX) ====================================
|
|
||||||
// =========================================================================
|
|
||||||
|
|
||||||
#if defined(__osf__) || defined(DECOSF1)
|
|
||||||
#include "ethernet.h-dec"
|
|
||||||
#elif defined(__sgi) || defined(IRIX)
|
|
||||||
#include "ethernet.h-sgi"
|
|
||||||
#else
|
|
||||||
static TCollection_AsciiString Ethernet(){
|
|
||||||
struct utsname info;
|
|
||||||
uname(&info);
|
|
||||||
char noaddress[100];
|
|
||||||
strcat(noaddress,"NO-ETHERNET-ADDRESS-AVAILABLE-ON-");
|
|
||||||
TCollection_AsciiString result(strcat(noaddress,info.sysname));
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// =========================================================================
|
|
||||||
TCollection_AsciiString OSD_Host::EthernetAddress(){
|
|
||||||
TCollection_AsciiString result;
|
|
||||||
result = Ethernet();
|
|
||||||
return (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
OSD_OEMType OSD_Host::MachineType(){
|
OSD_OEMType OSD_Host::MachineType(){
|
||||||
struct utsname info;
|
struct utsname info;
|
||||||
@ -250,7 +222,6 @@ static BOOL fInit = FALSE;
|
|||||||
static TCollection_AsciiString hostName;
|
static TCollection_AsciiString hostName;
|
||||||
static TCollection_AsciiString version;
|
static TCollection_AsciiString version;
|
||||||
static TCollection_AsciiString interAddr;
|
static TCollection_AsciiString interAddr;
|
||||||
static TCollection_AsciiString etherAddr;
|
|
||||||
static Standard_Integer memSize;
|
static Standard_Integer memSize;
|
||||||
|
|
||||||
OSD_Host :: OSD_Host () {
|
OSD_Host :: OSD_Host () {
|
||||||
@ -359,12 +330,6 @@ TCollection_AsciiString OSD_Host :: InternetAddress () {
|
|||||||
|
|
||||||
} // end OSD_Host :: InternetAddress
|
} // end OSD_Host :: InternetAddress
|
||||||
|
|
||||||
TCollection_AsciiString OSD_Host :: EthernetAddress () {
|
|
||||||
|
|
||||||
return etherAddr;
|
|
||||||
|
|
||||||
} // end EthernatAddress
|
|
||||||
|
|
||||||
OSD_OEMType OSD_Host :: MachineType () {
|
OSD_OEMType OSD_Host :: MachineType () {
|
||||||
|
|
||||||
return OSD_PC;
|
return OSD_PC;
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
#ifdef HAVE_NET_IF_H
|
|
||||||
# include <net/if.h>
|
|
||||||
#endif
|
|
||||||
extern "C" { int socket ( int addr, int type, int protocol ); }
|
|
||||||
/* phn:20/4/94:delete:begin:because not the same signature in </sys/ioctl.h> */
|
|
||||||
/* extern "C" { int ioctl ( int d, unsigned long request, char *argp);} */
|
|
||||||
/* phn:20/4/94:delete:end:because not the same signature in </sys/ioctl.h> */
|
|
||||||
extern "C" { int close ( int filedes ); }
|
|
||||||
|
|
||||||
|
|
||||||
Standard_CString Ethernet() {
|
|
||||||
struct ifdevea devea;
|
|
||||||
Standard_CString result;
|
|
||||||
static char *ether_devices[] = {
|
|
||||||
"qe0",
|
|
||||||
"se0",
|
|
||||||
"ln0",
|
|
||||||
"de0",
|
|
||||||
"ni0",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
char name[32];
|
|
||||||
long *eth;
|
|
||||||
int e[6]; // For byte to int conversions
|
|
||||||
int sock, i;
|
|
||||||
|
|
||||||
/* we need a socket */
|
|
||||||
sock = socket (AF_INET, SOCK_DGRAM, 0);
|
|
||||||
if (sock < 0) // Error : "Socket for Ethernet device localisation"
|
|
||||||
return(result);
|
|
||||||
|
|
||||||
/* loop until we find a device or we error out */
|
|
||||||
for (i = 0; ether_devices[i] != NULL; i++) {
|
|
||||||
/* setup the device name */
|
|
||||||
strcpy (&devea.ifr_name[0], ether_devices[i]);
|
|
||||||
|
|
||||||
/* read the interface address */
|
|
||||||
/* phn:20/4/94:update:begin:because not the same signature in </sys/ioctl.h> */
|
|
||||||
if (ioctl (sock, SIOCRPHYSADDR, &devea) < 0) { // error ?
|
|
||||||
/* if (ioctl (sock, (unsigned long)SIOCRPHYSADDR, (char*) &devea) < 0) { */ // error ?
|
|
||||||
/* phn:20/4/94:update:end:because not the same signature in </sys/ioctl.h> */
|
|
||||||
if (errno == ENXIO) { // doesn't exist, try next device
|
|
||||||
continue;
|
|
||||||
} else { // unexpected error
|
|
||||||
//perror (&devea.ifr_name[0]);
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
} else break; // found one, break out
|
|
||||||
} /* for ... */
|
|
||||||
|
|
||||||
close (sock);
|
|
||||||
|
|
||||||
if (ether_devices[i] == NULL) // Error : no Ethernet device
|
|
||||||
return(result);
|
|
||||||
|
|
||||||
// unsigned char to int conversions
|
|
||||||
|
|
||||||
e[0] = (unsigned char)devea.default_pa[0];
|
|
||||||
e[1] = (unsigned char)devea.default_pa[1];
|
|
||||||
e[2] = (unsigned char)devea.default_pa[2];
|
|
||||||
e[3] = (unsigned char)devea.default_pa[3];
|
|
||||||
e[4] = (unsigned char)devea.default_pa[4];
|
|
||||||
e[5] = (unsigned char)devea.default_pa[5];
|
|
||||||
|
|
||||||
sprintf(name,"%x:%x:%x:%x:%x:%x",e[0],e[1],e[2],e[3],e[4],e[5]);
|
|
||||||
result = name;
|
|
||||||
return(result);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +0,0 @@
|
|||||||
#include <net/if.h>
|
|
||||||
#include <net/raw.h>
|
|
||||||
Standard_CString Ethernet() {
|
|
||||||
Standard_CString result;
|
|
||||||
static char *ether_devices[]={
|
|
||||||
"ec0",
|
|
||||||
"enp0",
|
|
||||||
"et0",
|
|
||||||
"fxp0",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
int sock,i;
|
|
||||||
int e[6];
|
|
||||||
struct ifreq ifreq;
|
|
||||||
static char buffer[16];
|
|
||||||
|
|
||||||
sock = socket(AF_RAW,SOCK_RAW,RAWPROTO_DRAIN);
|
|
||||||
if (sock < 0) /* Error : "drain_open:could not open socket" */
|
|
||||||
return(result);
|
|
||||||
|
|
||||||
for (i=0; ether_devices[i] != NULL; i++){
|
|
||||||
strcpy(ifreq.ifr_name, ether_devices[i]); /* Puts name */
|
|
||||||
|
|
||||||
if (ioctl(sock, SIOCGIFADDR, (char *) &ifreq) < 0)
|
|
||||||
if (errno == ENXIO) continue;
|
|
||||||
else /* Error : "drain:getmyaddr:cannot get raw address" */
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
e[0] = (unsigned char)ifreq.ifr_addr.sa_data[0];
|
|
||||||
e[1] = (unsigned char)ifreq.ifr_addr.sa_data[1];
|
|
||||||
e[2] = (unsigned char)ifreq.ifr_addr.sa_data[2];
|
|
||||||
e[3] = (unsigned char)ifreq.ifr_addr.sa_data[3];
|
|
||||||
e[4] = (unsigned char)ifreq.ifr_addr.sa_data[4];
|
|
||||||
e[5] = (unsigned char)ifreq.ifr_addr.sa_data[5];
|
|
||||||
|
|
||||||
sprintf(buffer,"%x:%x:%x:%x:%x:%x", e[0],e[1],e[2],e[3],e[4],e[5]);
|
|
||||||
close(sock);
|
|
||||||
|
|
||||||
result = buffer;
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
@ -29,7 +29,6 @@ Standard_ExtCharacter.cxx
|
|||||||
Standard_ExtCharacter.hxx
|
Standard_ExtCharacter.hxx
|
||||||
Standard_ExtString.cxx
|
Standard_ExtString.cxx
|
||||||
Standard_ExtString.hxx
|
Standard_ExtString.hxx
|
||||||
Standard_Geteth.cxx
|
|
||||||
Standard_HashCode.cxx
|
Standard_HashCode.cxx
|
||||||
Standard_IStream.cxx
|
Standard_IStream.cxx
|
||||||
Standard_IStream.hxx
|
Standard_IStream.hxx
|
||||||
|
@ -1,235 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
Cree par JPT pour la protection SOK sur base CSF1.
|
|
||||||
A ce jour on reconnait comme machine:
|
|
||||||
- SUN/SOLARIS
|
|
||||||
- ALPHA/OSF
|
|
||||||
- SGI/IRIX
|
|
||||||
Pour SUN et SGI on recupere le numero unique du host (hostid).
|
|
||||||
Pour ALPHA on recupere l'adresse ethernet de la machine (ce qui est
|
|
||||||
tout de meme beaucoup plus sur).
|
|
||||||
|
|
||||||
*/
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SOCKET_H
|
|
||||||
# include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_SYSTEMINFO_H
|
|
||||||
# include <sys/systeminfo.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_IOCTL_H
|
|
||||||
# include <sys/ioctl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_NET_IF_H
|
|
||||||
# include <net/if.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <Standard_Stream.hxx>
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_UTSNAME_H
|
|
||||||
# include <sys/utsname.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__sun) || defined(SOLARIS)
|
|
||||||
extern "C" { int sysinfo (int command , char *name, long namelen);}
|
|
||||||
int atoi (char *);
|
|
||||||
#elif defined(__sgi) || defined(IRIX)
|
|
||||||
extern "C" {int sysid (unsigned char *);}
|
|
||||||
extern "C" {int atoi (const char *str);}
|
|
||||||
#elif defined(__osf__) || defined(DECOSF1)
|
|
||||||
// generic interface stuctures
|
|
||||||
#include <string.h>
|
|
||||||
char *ether_devices[] = {
|
|
||||||
"qe0",
|
|
||||||
"se0",
|
|
||||||
"ln0",
|
|
||||||
"de0",
|
|
||||||
"ni0",
|
|
||||||
"tu0",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
void Geteth(int tab[])
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
{
|
|
||||||
#if defined(__sun) || defined(SOLARIS)
|
|
||||||
/* Returns a SOLARIS host identification in 2 words */
|
|
||||||
unsigned int i;
|
|
||||||
char provider[16];
|
|
||||||
char serial[16];
|
|
||||||
|
|
||||||
i = (unsigned int ) sysinfo(SI_HW_PROVIDER,provider,16);
|
|
||||||
|
|
||||||
i = (unsigned int ) sysinfo(SI_HW_SERIAL,serial,16);
|
|
||||||
|
|
||||||
|
|
||||||
/*printf("\nProvider : %s Serial : %s\n",provider,serial);*/
|
|
||||||
|
|
||||||
sscanf(serial,"%d",&i);
|
|
||||||
|
|
||||||
tab[0] = 0;
|
|
||||||
tab[1] = 0;
|
|
||||||
|
|
||||||
tab[1] = tab[1] | (i >> 24);
|
|
||||||
tab[1] = tab[1] | ( (i >> 8 ) & 0x0000ff00);
|
|
||||||
tab[1] = tab[1] | ( (i << 8 ) & 0x00ff0000);
|
|
||||||
tab[1] = tab[1] | ( (i << 24) & 0xff000000);
|
|
||||||
|
|
||||||
tab[1] = -tab[1];
|
|
||||||
|
|
||||||
|
|
||||||
// unsigned int stat;
|
|
||||||
// char name[100];
|
|
||||||
// long len = 100;
|
|
||||||
// stat = sysinfo (SI_HW_SERIAL,name,len);
|
|
||||||
// if (stat != -1){ // It is correct.....
|
|
||||||
// int i = atoi (name);
|
|
||||||
// tab[0] = 0;
|
|
||||||
// tab[1] = 0;
|
|
||||||
// tab[1] = tab[1] | (i >> 24);
|
|
||||||
// tab[1] = tab[1] | ( (i >> 8) & 0x0000ff00);
|
|
||||||
// tab[1] = tab[1] | ( (i << 8) & 0x00ff0000);
|
|
||||||
// tab[1] = tab[1] | ( (i << 24) & 0xff000000);
|
|
||||||
// tab[1] = -tab[1];
|
|
||||||
// }
|
|
||||||
// else { // It is nor normal : exit !
|
|
||||||
// printf("SOK_Utility-Internal_Error_1:Unable to get hardware-specific serial number, errno = %d.\n",errno);
|
|
||||||
// exit(0);
|
|
||||||
// }
|
|
||||||
|
|
||||||
#elif defined(__sgi) || defined(IRIX)
|
|
||||||
|
|
||||||
/* Creee par JPT le 29-Oct-1992
|
|
||||||
|
|
||||||
Renvoie l'identification d'un hostname SGI dans 2 mots.
|
|
||||||
|
|
||||||
Sur SGI l'appel a sysid renvois 16 caracteres qui identifie de
|
|
||||||
fa on unique une machine.
|
|
||||||
|
|
||||||
Sur SGI/xxxx avec xxxx autre que CRIMSON seuls les 8 premiers
|
|
||||||
caracteres sont significatifs. Les 8 autres sont nuls.
|
|
||||||
|
|
||||||
Pour tre homogene avec les autres plateformes on prend les 16
|
|
||||||
caracteres et on rend 12 chiffres hexadecimaux.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
unsigned int i ;
|
|
||||||
unsigned int tt [4] ;
|
|
||||||
char str[16] ;
|
|
||||||
|
|
||||||
sysid ( (unsigned char* )str ) ;
|
|
||||||
tt[0] = tt[1] = tt[2] = tt[3] = 0 ;
|
|
||||||
tt[0] = atoi (str) ;
|
|
||||||
tab[0] = 0 ;
|
|
||||||
tab[1] = 0 ;
|
|
||||||
i = tt[2] ^ tt[3] ;
|
|
||||||
i = i ^ tt [0] ;
|
|
||||||
tab[1] = tab[1] | (i >> 24) ;
|
|
||||||
tab[1] = tab[1] | ( (i >> 8 ) & 0x0000ff00) ;
|
|
||||||
tab[1] = tab[1] | ( (i << 8 ) & 0x00ff0000) ;
|
|
||||||
tab[1] = tab[1] | ( (i << 24) & 0xff000000) ;
|
|
||||||
tab[1] = -tab[1] ;
|
|
||||||
|
|
||||||
i = tt[1] >> 16 ;
|
|
||||||
i = i ^ ( tt[1] & 0x0000ffff ) ;
|
|
||||||
tab[0] = i ;
|
|
||||||
tab[0] = -tab[0] ;
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined(__osf__) || defined(DECOSF1)
|
|
||||||
|
|
||||||
struct ifdevea devea;
|
|
||||||
|
|
||||||
int ss, i;
|
|
||||||
|
|
||||||
char id[8];
|
|
||||||
int *pid;
|
|
||||||
|
|
||||||
ss = socket (AF_INET, SOCK_DGRAM, 0);
|
|
||||||
if (ss < 0)
|
|
||||||
return;
|
|
||||||
else {
|
|
||||||
for (i = 0; ether_devices[i] != NULL; i++) {
|
|
||||||
strcpy (&devea.ifr_name[0], ether_devices[i]);
|
|
||||||
if (ioctl (ss, SIOCRPHYSADDR, &devea) < 0) {
|
|
||||||
if (errno == ENXIO) // doesn't exist, try next device
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
break; // found one, break out
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
close (ss);
|
|
||||||
|
|
||||||
if (ether_devices[i] == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
id[3] = 0 ;
|
|
||||||
id[2] = 0 ;
|
|
||||||
id[4] = devea.default_pa[0];
|
|
||||||
id[5] = devea.default_pa[1];
|
|
||||||
|
|
||||||
id[6] = devea.default_pa[2];
|
|
||||||
id[7] = devea.default_pa[3];
|
|
||||||
id[0] = devea.default_pa[4];
|
|
||||||
id[1] = devea.default_pa[5];
|
|
||||||
|
|
||||||
|
|
||||||
pid = (int *)&id ;
|
|
||||||
tab[0] = pid[0] ;
|
|
||||||
tab[1] = pid[1] ;
|
|
||||||
tab[0] = - tab[0] ;
|
|
||||||
tab[1] = - tab[1] ;
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined(__hpux) || defined(HPUX)
|
|
||||||
long i;
|
|
||||||
struct utsname un;
|
|
||||||
|
|
||||||
tab[0] = 0;
|
|
||||||
tab[1] = 0;
|
|
||||||
if (uname(&un) != -1)
|
|
||||||
{sscanf(un.idnumber,"%d",&i);
|
|
||||||
tab[1] = int( tab[1] | (i >> 24) ) ;
|
|
||||||
tab[1] = int( tab[1] | ( (i >> 8 ) & 0x0000ff00) ) ;
|
|
||||||
tab[1] = int( tab[1] | ( (i << 8 ) & 0x00ff0000) ) ;
|
|
||||||
tab[1] = int( tab[1] | ( (i << 24) & 0xff000000) ) ;
|
|
||||||
|
|
||||||
tab[1] = -tab[1];};
|
|
||||||
|
|
||||||
//return ((long) tab);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user