summaryrefslogtreecommitdiff
path: root/win32/support.c
diff options
context:
space:
mode:
authorDmitry Chagin <dchagin@FreeBSD.org>2017-03-18 21:41:53 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2017-03-18 21:41:53 +0000
commit6895abeab878a30d05c122c2467990ebb47bd58a (patch)
treec83c107f25929f537445d21738c490d53c59b94d /win32/support.c
parent0bc8d6575fcb65f394796e060efa34444d983b7b (diff)
Notes
Diffstat (limited to 'win32/support.c')
-rw-r--r--win32/support.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/win32/support.c b/win32/support.c
index dd3c117af693..acc0f4e906f9 100644
--- a/win32/support.c
+++ b/win32/support.c
@@ -1,4 +1,4 @@
-/*$Header: /p/tcsh/cvsroot/tcsh/win32/support.c,v 1.14 2008/08/31 14:09:01 amold Exp $*/
+/*$Header: /p/tcsh/cvsroot/tcsh/win32/support.c,v 1.16 2014/08/17 02:56:37 amold Exp $*/
/*-
* Copyright (c) 1980, 1991 The Regents of the University of California.
* All rights reserved.
@@ -46,6 +46,7 @@
#include "sh.h"
#include "nt.const.h"
+#pragma warning(disable:6001)
DWORD gdwPlatform,gdwVersion;
unsigned short __nt_really_exec = 0,__nt_child_nohupped =0;
@@ -84,7 +85,6 @@ void nt_init(void) {
gcurr_drive=temp[0];
}
#endif SECURE_CD
-
_set_invalid_parameter_handler(do_nothing);
init_stdio();
nt_init_signals();
@@ -185,6 +185,7 @@ void getmachine (void) {
osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+#pragma warning(suppress:4996 28159) //deprecated function
if (!GetVersionEx(&osver)) {
MessageBox(NULL,"GetVersionEx failed in getmachine",
"tcsh",MB_ICONHAND);
@@ -197,17 +198,18 @@ void getmachine (void) {
ostype = "WindowsNT";
ostr = "Windows NT";
- (void)StringCbPrintf(temp,sizeof(temp),"%s %d.%d Build %d (%s)",
+ (void)StringCbPrintf(temp,(int)sizeof(temp),"%s %u.%u Build %u (%s)",
ostr,
- osver.dwMajorVersion,osver.dwMinorVersion,
+ osver.dwMajorVersion,
+ osver.dwMinorVersion,
osver.dwBuildNumber,
osver.szCSDVersion[0]?osver.szCSDVersion:"");
tsetenv(STRHOSTTYPE,str2short(temp));
}
else if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
ostype = "Windows9x";
- (void)StringCbPrintf(temp,sizeof(temp),
- "Win9x %d.%d:%d",osver.dwMajorVersion,osver.dwMinorVersion,
+ (void)StringCbPrintf(temp,(int)sizeof(temp),
+ "Win9x %u.%u:%u",osver.dwMajorVersion,osver.dwMinorVersion,
LOWORD(osver.dwBuildNumber));
tsetenv(STRHOSTTYPE,str2short(temp));
}
@@ -222,23 +224,23 @@ void getmachine (void) {
( sysinfo.wProcessorLevel > 9) )
sysinfo.wProcessorLevel = 3;
- (void)StringCbPrintf(temp,sizeof(temp),
- "i%d86",sysinfo.wProcessorLevel);
+ (void)StringCbPrintf(temp,(int)sizeof(temp),
+ "i%u86",sysinfo.wProcessorLevel);
break;
case PROCESSOR_ARCHITECTURE_ALPHA:
- (void)StringCbPrintf(temp,sizeof(temp),"Alpha");
+ (void)StringCbPrintf(temp,(int)sizeof(temp),"Alpha");
break;
case PROCESSOR_ARCHITECTURE_MIPS:
- (void)StringCbPrintf(temp,sizeof(temp),"Mips");
+ (void)StringCbPrintf(temp,(int)sizeof(temp),"Mips");
break;
case PROCESSOR_ARCHITECTURE_PPC:
- (void)StringCbPrintf(temp,sizeof(temp),"PPC");
+ (void)StringCbPrintf(temp,(int)sizeof(temp),"PPC");
break;
case PROCESSOR_ARCHITECTURE_AMD64:
- (void)StringCbPrintf(temp,sizeof(temp),"AMD64");
+ (void)StringCbPrintf(temp,(int)sizeof(temp),"AMD64");
break;
default:
- (void)StringCbPrintf(temp,sizeof(temp),"Unknown");
+ (void)StringCbPrintf(temp,(int)sizeof(temp),"Unknown");
break;
}
tsetenv(STRMACHTYPE,str2short(temp));
@@ -574,6 +576,7 @@ void silly_entry(void *peb) {
osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+#pragma warning(suppress:4996 28159) //deprecated function
if (!GetVersionEx(&osver)) {
MessageBox(NULL,"GetVersionEx failed","tcsh",MB_ICONHAND);
ExitProcess(0xFF);
@@ -714,7 +717,7 @@ skippy:
rc = GetEnvironmentVariable("Path",path1,0);
- if ( rc !=0) {
+ if ( rc !=0 && path1) {
path1 =heap_alloc(rc);
@@ -792,6 +795,9 @@ char *concat_args_and_quote(char **args, char **poriginalPtr,char **cstr,
dprintf("entering concat_args_and_quote\n");
tempquotedbuf = heap_alloc(tqlen);
+ if(!tempquotedbuf) {
+ return NULL;
+ }
noquoteprotect = (short)(varval(STRNTnoquoteprotect) != STRNULL);
/*
@@ -914,8 +920,12 @@ char *fix_path_for_child(void) {
oldpath = heap_alloc(len+1);
pathstr = heap_alloc(len+1);
+ if(!oldpath || !pathstr) {
+ return NULL;
+ }
len = GetEnvironmentVariable("PATH",oldpath,len+1);
+#pragma warning(suppress:6102)
memcpy(pathstr,oldpath,len);
ptr = pathstr;