Changeset 918 for trunk/dll/systemf.c


Ignore:
Timestamp:
Jan 12, 2008, 9:16:37 PM (18 years ago)
Author:
Gregg Young
Message:

Fix CheckApp_QuoteAddExe to return a pointer on the stack instead of a string. Use MAXCOMLINESTRG for command line length.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/systemf.c

    r917 r918  
    4343static PSZ pszSrcFile = __FILE__;
    4444
    45 #define MAXSTRG (4096)                  /* used to build command line strings */
    46 
    4745/**
    4846 * Bring session foreground
     
    8381  /* executes the command once for all files in list */
    8482
    85   char path[CCHMAXPATH], commandline[2048], modpath[CCHMAXPATH], listfile[CCHMAXPATH],
     83  char path[CCHMAXPATH], commandline[MAXCOMLINESTRG], modpath[CCHMAXPATH], listfile[CCHMAXPATH],
    8684       *p, *pp, drive, *file, *ext, *dot;
    8785  register int x;
     
    676674
    677675  rc = DosAllocMem((PVOID)&pszPgm,
    678                    MAXSTRG,
     676                   MAXCOMLINESTRG,
    679677                   PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE);
    680678  if (rc) {
     
    721719      if (temp) {
    722720        rc = DosAllocMem((PVOID)&pszArgs,
    723                          MAXSTRG * 2,
     721                         MAXCOMLINESTRG * 2,
    724722                         PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE);
    725723        if (rc)
     
    854852      if (~type & FULLSCREEN)
    855853        type |= WINDOWED;
    856       rc = DosAllocMem((PVOID) & pszArgs, MAXSTRG * 2,
     854      rc = DosAllocMem((PVOID) & pszArgs, MAXCOMLINESTRG * 2,
    857855                       PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE);
    858856      if (rc) {
     
    12371235    ulOptions |= SAF_STARTCHILDAPP;
    12381236
    1239   executable = xmallocz(MAXSTRG,pszSrcFile,__LINE__);
     1237  executable = xmallocz(MAXCOMLINESTRG, pszSrcFile, __LINE__);
    12401238  if (executable) {
    12411239    va_start(parguments, formatstring);
     
    12441242    strip_lead_char(" \t", executable);
    12451243    if (*executable) {
    1246       parameters = xmalloc(MAXSTRG,pszSrcFile,__LINE__);
     1244      parameters = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
    12471245      if (parameters) {
    12481246        p = executable;
     
    13181316}
    13191317
    1320 PSZ CheckApp_QuoteAddExe(PSZ pszPgm)
     1318PSZ CheckApp_QuoteAddExe(PSZ pszQuotedCompletePgm, PSZ pszPgm)
    13211319{
    1322   // 11 Jan 08 SHL fixme to not return quoted string on stack
    1323   // 11 Jan 08 SHL fixme to have javadoc comments
    1324   char szTempPgm[2048], tempcom[2048], temparg[2048];
     1320  char tempcom[MAXCOMLINESTRG], temparg[MAXCOMLINESTRG];
    13251321  char *offset = '\0', *offsetexe, *offsetcom, *offsetcmd, *offsetbtm, *offsetbat;
    13261322  APIRET ret;
     
    13311327  HDIR hdirFindHandle = HDIR_CREATE;
    13321328  ULONG ulFindCount = 1;
    1333   PSZ pszQuotedCompletePgm;
     1329  PSZ pszTempPgm = pszQuotedCompletePgm;
    13341330
    13351331  bstrip(pszPgm);
     
    13961392      else
    13971393        ret = DosQueryAppType(tempcom, &ulAppType);
    1398       BldQuotedFileName(szTempPgm, tempcom);
     1394      BldQuotedFileName(pszTempPgm, tempcom);
    13991395      //printf("%d A", ret); fflush(stdout);
    14001396      if (ret) {
    1401         ret = saymsg(MB_YESNO,
    1402                      HWND_DESKTOP,
    1403                      NullStr,
    1404                      GetPString(IDS_PROGRAMNOTFOUNDTEXT),
    1405                      pszPgm);
    1406         if (ret == MBID_YES)
    1407           pszQuotedCompletePgm = pszPgm;
    1408         else {
    1409           fCancelAction = TRUE;
    1410           pszQuotedCompletePgm = pszPgm;
    1411         }
    1412       }
    1413       else {
    1414         if (temparg[0] != ' ')
    1415           strcat(szTempPgm, " ");
    1416         strcat(szTempPgm, temparg);
    1417         pszQuotedCompletePgm = szTempPgm;
     1397        ret = saymsg(MB_YESNO,
     1398                     HWND_DESKTOP,
     1399                     NullStr,
     1400                     GetPString(IDS_PROGRAMNOTFOUNDTEXT),
     1401                     pszPgm);
     1402        if (ret == MBID_YES){
     1403          pszTempPgm = pszPgm;
     1404      }
     1405        else{
     1406          fCancelAction = TRUE;
     1407          pszTempPgm = pszPgm;
     1408        }
     1409      }
     1410      else{
     1411        if (temparg[0] != ' ')
     1412          strcat(pszTempPgm, " ");
     1413        strcat(pszTempPgm, temparg);
    14181414      }
    14191415
     
    14471443        }
    14481444      }
    1449       if (!ret) {
    1450         BldQuotedFileName(szTempPgm, tempcom);
    1451         strcpy(temparg, pszPgm + strlen(tempcom) - 3);
    1452         if ((temparg[0] == '\"' && temparg[1] == ' ') ||
    1453              !strstr(pszPgm, "\\:" ) ||
    1454              strchr(temparg, '\"') == strrchr(temparg, '\"'))
    1455           remove_first_occurence_of_character("\"", temparg);
    1456         if (strchr(temparg, '\"') != strrchr(temparg, '\"'))
    1457           saymsg(MB_OK, HWND_DESKTOP,
    1458                  NullStr,
    1459                  GetPString(IDS_QUOTESINARGSTEXT),
    1460                  pszPgm);
    1461         if (temparg[0] != ' ')
    1462           strcat(szTempPgm, " ");
    1463         strcat(szTempPgm, temparg);
    1464         pszQuotedCompletePgm = szTempPgm;
     1445      if (!ret){
     1446        BldQuotedFileName(pszTempPgm, tempcom);
     1447        strcpy(temparg, pszPgm + strlen(tempcom) - 3);
     1448        if ((temparg[0] == '\"' && temparg[1] == ' ') ||
     1449             !strstr(pszPgm, "\\:" ) ||
     1450             strchr(temparg, '\"') == strrchr(temparg, '\"'))
     1451          remove_first_occurence_of_character("\"", temparg);
     1452        if (strchr(temparg, '\"') != strrchr(temparg, '\"'))
     1453          saymsg(MB_OK, HWND_DESKTOP,
     1454                 NullStr,
     1455                 GetPString(IDS_QUOTESINARGSTEXT),
     1456                 pszPgm);
     1457        if (temparg[0] != ' ')
     1458          strcat(pszTempPgm, " ");
     1459        strcat(pszTempPgm, temparg);
    14651460      }
    14661461      else {
    1467         ret = saymsg(MB_OK,
    1468                      HWND_DESKTOP,
    1469                      NullStr,
    1470                      GetPString(IDS_PROGRAMNOTEXE2TEXT),
    1471                      pszPgm);
    1472           fCancelAction = TRUE;
    1473           pszQuotedCompletePgm = pszPgm;
     1462        ret = saymsg(MB_OK,
     1463                     HWND_DESKTOP,
     1464                     NullStr,
     1465                     GetPString(IDS_PROGRAMNOTEXE2TEXT),
     1466                     pszPgm);
     1467          fCancelAction = TRUE;
     1468          pszTempPgm = pszPgm;
    14741469      }
    14751470    }
     
    14951490                         ulResultBufLen, &ulFindCount, FIL_STANDARD);
    14961491
    1497     BldQuotedFileName(szTempPgm, tempcom);
     1492    BldQuotedFileName(pszTempPgm, tempcom);
    14981493    //printf("%d %s ", ret, tempcom); fflush(stdout);
    14991494    if (ret) {
     
    15121507    }
    15131508    ret = saymsg(MB_YESNOCANCEL,
    1514                    HWND_DESKTOP,
    1515                    NullStr,
    1516                    GetPString(IDS_PROGRAMNOTEXE3TEXT),
    1517                    pszPgm, szTempPgm);
    1518       if (ret == MBID_YES) {
    1519         if (temparg[0] != ' ')
    1520           strcat(szTempPgm, " ");
    1521         strcat(szTempPgm, temparg);
    1522         pszQuotedCompletePgm = szTempPgm;
    1523       }
    1524       if (ret == MBID_CANCEL) {
    1525         fCancelAction = TRUE;
    1526         pszQuotedCompletePgm = pszPgm;
    1527       }
    1528       else
    1529         pszQuotedCompletePgm = pszPgm;
    1530     }
    1531     return pszQuotedCompletePgm;
     1509                   HWND_DESKTOP,
     1510                   NullStr,
     1511                   GetPString(IDS_PROGRAMNOTEXE3TEXT),
     1512                   pszPgm, pszTempPgm);
     1513      if (ret == MBID_YES){
     1514        if (temparg[0] != ' ')
     1515          strcat(pszTempPgm, " ");
     1516        strcat(pszTempPgm, temparg);
     1517      }
     1518      if (ret == MBID_CANCEL){
     1519        fCancelAction = TRUE;
     1520        pszTempPgm = pszPgm;
     1521      }
     1522    }
    15321523  }
    1533   return pszPgm;
     1524  else
     1525    pszTempPgm = pszPgm;
     1526  return pszQuotedCompletePgm;
    15341527}
    15351528
Note: See TracChangeset for help on using the changeset viewer.