Changeset 918 for trunk/dll/notebook.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/notebook.c

    r917 r918  
    193193    PrfWriteProfileString(fmprof, appname, "DefArc", szDefArc);
    194194    {
    195       CHAR szBuf[CCHMAXPATH], *psz;
    196 
    197       WinQueryDlgItemText(hwnd, CFGA_VIRUS, CCHMAXPATH, szBuf);
    198       szBuf[CCHMAXPATH - 1] = 0;
    199       if (strcmp(szBuf, virus)) {
    200         psz = CheckApp_QuoteAddExe(szBuf);
    201         memcpy(virus, psz, strlen(psz) + 1);
    202         if (!strchr(virus, '%') && strlen(virus) > 3)
    203           strcat(virus, " %p");
     195      CHAR szCLBuf[MAXCOMLINESTRG], szPathBuf[CCHMAXPATH];
     196      PSZ psz;
     197
     198      psz = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     199      WinQueryDlgItemText(hwnd, CFGA_VIRUS, MAXCOMLINESTRG, szCLBuf);
     200      szCLBuf[MAXCOMLINESTRG - 1] = 0;
     201      if (strcmp(szCLBuf, virus)){
     202        CheckApp_QuoteAddExe(psz, szCLBuf);
     203        memcpy(virus, psz, strlen(psz) + 1);
     204        if (!strchr(virus, '%') && strlen(virus) > 3)
     205          strcat(virus, " %p");
    204206      }
    205207      if (!*virus)
    206208        strcpy(virus, "OS2SCAN.EXE %p /SUB /A");
    207       WinQueryDlgItemText(hwnd, CFGA_EXTRACTPATH, CCHMAXPATH, szBuf);
    208       szBuf[CCHMAXPATH - 1] = 0;
    209       bstrip(szBuf);
    210 
    211       if (strcmp(extractpath, szBuf)) {
    212         memcpy(extractpath, szBuf, strlen(szBuf) + 1);
    213         if (*extractpath) {
    214           MakeFullName(extractpath);
    215           if (IsFile(extractpath)) {
    216             ulResult = saymsg(MB_YESNOCANCEL | MB_ICONQUESTION | MB_DEFBUTTON1, HWND_DESKTOP,
    217                               GetPString(IDS_WARNINGTEXT),
    218                               GetPString(IDS_EXTPATHNOTVALIDTEXT),
    219                               extractpath);
    220             if (ulResult == MBID_YES)
    221               *extractpath = 0;
    222             if (ulResult == MBID_CANCEL) {
    223               WinDlgBox(HWND_DESKTOP,
     209      WinQueryDlgItemText(hwnd, CFGA_EXTRACTPATH, CCHMAXPATH, szPathBuf);
     210      szPathBuf[CCHMAXPATH - 1] = 0;
     211      bstrip(szPathBuf);
     212      if (strcmp(extractpath, szPathBuf)) {
     213        memcpy(extractpath, szPathBuf, strlen(szPathBuf) + 1);
     214        if (*extractpath){
     215          MakeFullName(extractpath);
     216          if (IsFile(extractpath)) {
     217            ulResult = saymsg(MB_YESNOCANCEL | MB_ICONQUESTION | MB_DEFBUTTON1, HWND_DESKTOP,
     218                              GetPString(IDS_WARNINGTEXT),
     219                              GetPString(IDS_EXTPATHNOTVALIDTEXT),
     220                              extractpath);
     221            if (ulResult == MBID_YES)
     222              *extractpath = 0;
     223            if (ulResult == MBID_CANCEL){
     224              WinDlgBox(HWND_DESKTOP,
    224225                        hwnd,
    225226                        CfgDlgProc,
     
    227228                        CFG_FRAME,
    228229                        MPFROMLONG(IDM_ARCHIVERSETTINGS));
    229               break;
    230             }
    231           }
    232         }
     230              break;
     231            }
     232          }
     233        }
    233234      }
    234235    }
     
    364365  case WM_INITDLG:
    365366    WinSendDlgItemMsg(hwnd, CFGV_VIEWER, EM_SETTEXTLIMIT,
    366                       MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     367                      MPFROM2SHORT(MAXCOMLINESTRG, 0), MPVOID);
    367368    WinSendDlgItemMsg(hwnd, CFGV_EDITOR, EM_SETTEXTLIMIT,
    368                       MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     369                      MPFROM2SHORT(MAXCOMLINESTRG, 0), MPVOID);
    369370    WinSendDlgItemMsg(hwnd, CFGV_BINVIEW, EM_SETTEXTLIMIT,
    370                       MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     371                      MPFROM2SHORT(MAXCOMLINESTRG, 0), MPVOID);
    371372    WinSendDlgItemMsg(hwnd, CFGV_BINED, EM_SETTEXTLIMIT,
    372                       MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     373                      MPFROM2SHORT(MAXCOMLINESTRG, 0), MPVOID);
    373374    WinEnableWindow(WinWindowFromID(hwnd, CFGV_FIND), FALSE);
    374375    PostMsg(hwnd, UM_UNDO, MPVOID, MPVOID);
     
    456457  case WM_CLOSE:
    457458    {
    458       CHAR szBuf[CCHMAXPATH], *psz;
    459 
    460       WinQueryDlgItemText(hwnd, CFGV_VIEWER, CCHMAXPATH, szBuf);
    461       szBuf[CCHMAXPATH - 1] = 0;
    462       if (strcmp(szBuf, viewer)) {
    463         psz = CheckApp_QuoteAddExe(szBuf);
    464         memcpy(viewer, psz, strlen(psz) + 1);
    465         if (!strchr(viewer, '%') && strlen(viewer) > 3)
    466           strcat(viewer, " %a");
    467       }
    468       WinQueryDlgItemText(hwnd, CFGV_EDITOR, CCHMAXPATH, szBuf);
    469       szBuf[CCHMAXPATH - 1] = 0;
    470       if (strcmp(szBuf, editor)) {
    471         psz = CheckApp_QuoteAddExe(szBuf);
    472         memcpy(editor, psz, strlen(psz) + 1);
    473         if (!strchr(editor, '%') && strlen(editor) > 3)
    474           strcat(editor, " %a");
    475       }
    476       WinQueryDlgItemText(hwnd, CFGV_BINVIEW, CCHMAXPATH, szBuf);
    477       szBuf[CCHMAXPATH - 1] = 0;
    478       if (strcmp(szBuf, binview)) {
    479         psz = CheckApp_QuoteAddExe(szBuf);
    480         memcpy(binview, psz, strlen(psz) + 1);
    481         if (!strchr(binview, '%') && strlen(binview) > 3)
    482           strcat(binview, " %a");
    483       }
    484       WinQueryDlgItemText(hwnd, CFGV_BINED, CCHMAXPATH, szBuf);
    485       szBuf[CCHMAXPATH - 1] = 0;
    486       if (strcmp(szBuf, bined)) {
    487         psz = CheckApp_QuoteAddExe(szBuf);
    488         memcpy(bined, psz, strlen(psz) + 1);
    489         if (!strchr(bined, '%') && strlen(bined) > 3)
    490           strcat(bined, " %a");
     459      CHAR szCLBuf[MAXCOMLINESTRG];
     460      PSZ psz;
     461
     462      psz = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     463      WinQueryDlgItemText(hwnd, CFGV_VIEWER, MAXCOMLINESTRG, szCLBuf);
     464      szCLBuf[MAXCOMLINESTRG - 1] = 0;
     465      if (strcmp(szCLBuf, viewer)){
     466        CheckApp_QuoteAddExe(psz, szCLBuf);
     467        memcpy(viewer, psz, strlen(psz) + 1);
     468        if (!strchr(viewer, '%') && strlen(viewer) > 3)
     469          strcat(viewer, " %a");
     470      }
     471      WinQueryDlgItemText(hwnd, CFGV_EDITOR, MAXCOMLINESTRG, szCLBuf);
     472      szCLBuf[MAXCOMLINESTRG - 1] = 0;
     473      if (strcmp(szCLBuf, editor)){
     474        CheckApp_QuoteAddExe(psz, szCLBuf);
     475        memcpy(editor, psz, strlen(psz) + 1);
     476        if (!strchr(editor, '%') && strlen(editor) > 3)
     477          strcat(editor, " %a");
     478      }
     479      WinQueryDlgItemText(hwnd, CFGV_BINVIEW, MAXCOMLINESTRG, szCLBuf);
     480      szCLBuf[MAXCOMLINESTRG - 1] = 0;
     481      if (strcmp(szCLBuf, binview)){
     482        CheckApp_QuoteAddExe(psz, szCLBuf);
     483        memcpy(binview, psz, strlen(psz) + 1);
     484        if (!strchr(binview, '%') && strlen(binview) > 3)
     485          strcat(binview, " %a");
     486      }
     487      WinQueryDlgItemText(hwnd, CFGV_BINED, MAXCOMLINESTRG, szCLBuf);
     488      szCLBuf[MAXCOMLINESTRG - 1] = 0;
     489      if (strcmp(szCLBuf, bined)){
     490        CheckApp_QuoteAddExe(psz, szCLBuf);
     491        memcpy(bined, psz, strlen(psz) + 1);
     492        if (!strchr(bined, '%') && strlen(bined) > 3)
     493          strcat(bined, " %a");
    491494      }
    492495      PrfWriteProfileString(fmprof, appname, "Viewer", viewer);
     
    530533                      MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
    531534    WinSendDlgItemMsg(hwnd, CFGH_FTPRUN, EM_SETTEXTLIMIT,
    532                       MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     535                      MPFROM2SHORT(MAXCOMLINESTRG, 0), MPVOID);
    533536    WinSendDlgItemMsg(hwnd, CFGH_HTTPRUN, EM_SETTEXTLIMIT,
    534                       MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     537                      MPFROM2SHORT(MAXCOMLINESTRG, 0), MPVOID);
    535538    WinSendDlgItemMsg(hwnd, CFGH_MAILRUN, EM_SETTEXTLIMIT,
    536                       MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     539                      MPFROM2SHORT(MAXCOMLINESTRG, 0), MPVOID);
    537540    WinSendDlgItemMsg(hwnd, CFGH_RUNMAILWORKDIR, EM_SETTEXTLIMIT,
    538541                      MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     
    648651    { // fixme these strings can be longer than CCHMAXPATH since
    649652      // they contain args.
    650       CHAR szBuf[CCHMAXPATH], *psz;
    651 
    652       WinQueryDlgItemText(hwnd, CFGH_RUNHTTPWORKDIR, CCHMAXPATH, szBuf);
    653       szBuf[CCHMAXPATH - 1] = 0;
    654       bstrip(szBuf);
    655       memcpy(httprundir, szBuf, strlen(szBuf) + 1);
    656       WinQueryDlgItemText(hwnd, CFGH_RUNFTPWORKDIR, CCHMAXPATH, szBuf);
    657       szBuf[CCHMAXPATH - 1] = 0;
    658       bstrip(szBuf);
    659       memcpy(ftprundir, szBuf, strlen(szBuf) + 1);
    660       WinQueryDlgItemText(hwnd, CFGH_RUNMAILWORKDIR, CCHMAXPATH, szBuf);
    661       szBuf[CCHMAXPATH - 1] = 0;
    662       bstrip(szBuf);
    663       memcpy(mailrundir, szBuf, strlen(szBuf) + 1);
    664       WinQueryDlgItemText(hwnd, CFGH_FTPRUN, CCHMAXPATH, szBuf);
    665       szBuf[CCHMAXPATH - 1] = 0;
    666       if (strcmp(szBuf, ftprun)) {
    667         psz = CheckApp_QuoteAddExe(szBuf);
    668         memcpy(ftprun, psz, strlen(psz) + 1);
    669       }
    670       WinQueryDlgItemText(hwnd, CFGH_HTTPRUN, CCHMAXPATH, szBuf);
    671       szBuf[CCHMAXPATH - 1] = 0;
    672       if (strcmp(szBuf, httprun)) {
    673         psz = CheckApp_QuoteAddExe(szBuf);
    674         memcpy(httprun, psz, strlen(psz) + 1);
    675       }
    676       WinQueryDlgItemText(hwnd, CFGH_MAILRUN, CCHMAXPATH, szBuf);
    677       szBuf[CCHMAXPATH - 1] = 0;
    678       if (strcmp(szBuf, mailrun)) {
    679         psz = CheckApp_QuoteAddExe(szBuf);
    680         memcpy(mailrun, psz, strlen(psz) + 1);
     653      CHAR szCLBuf[MAXCOMLINESTRG], szPathBuf[CCHMAXPATH];
     654      PSZ  psz;
     655
     656      psz = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     657      WinQueryDlgItemText(hwnd, CFGH_RUNHTTPWORKDIR, CCHMAXPATH, szPathBuf);
     658      szPathBuf[CCHMAXPATH - 1] = 0;
     659      bstrip(szPathBuf);
     660      memcpy(httprundir, szPathBuf, strlen(szPathBuf) + 1);
     661      WinQueryDlgItemText(hwnd, CFGH_RUNFTPWORKDIR, CCHMAXPATH, szPathBuf);
     662      szPathBuf[CCHMAXPATH - 1] = 0;
     663      bstrip(szPathBuf);
     664      memcpy(ftprundir, szPathBuf, strlen(szPathBuf) + 1);
     665      WinQueryDlgItemText(hwnd, CFGH_RUNMAILWORKDIR, CCHMAXPATH, szPathBuf);
     666      szPathBuf[CCHMAXPATH - 1] = 0;
     667      bstrip(szPathBuf);
     668      memcpy(mailrundir, szPathBuf, strlen(szPathBuf) + 1);
     669      WinQueryDlgItemText(hwnd, CFGH_FTPRUN, MAXCOMLINESTRG, szCLBuf);
     670      szCLBuf[MAXCOMLINESTRG - 1] = 0;
     671      if (strcmp(szCLBuf, ftprun)){
     672        CheckApp_QuoteAddExe(psz, szCLBuf);
     673        memcpy(ftprun, psz, strlen(psz) + 1);
     674      }
     675      WinQueryDlgItemText(hwnd, CFGH_HTTPRUN, MAXCOMLINESTRG, szCLBuf);
     676      szCLBuf[MAXCOMLINESTRG - 1] = 0;
     677      if (strcmp(szCLBuf, httprun)){
     678        CheckApp_QuoteAddExe(psz, szCLBuf);
     679        memcpy(httprun, psz, strlen(psz) + 1);
     680      }
     681      WinQueryDlgItemText(hwnd, CFGH_MAILRUN, MAXCOMLINESTRG, szCLBuf);
     682      szCLBuf[MAXCOMLINESTRG - 1] = 0;
     683      if (strcmp(szCLBuf, mailrun)){
     684        CheckApp_QuoteAddExe(psz, szCLBuf);
     685        memcpy(mailrun, psz, strlen(psz) + 1);
    681686      }
    682687      PrfWriteProfileString(fmprof, appname, "HttpRunDir", httprundir);
     
    11791184  case WM_INITDLG:
    11801185    WinSendDlgItemMsg(hwnd, CFGC_COMPARE, EM_SETTEXTLIMIT,
    1181                       MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     1186                      MPFROM2SHORT(MAXCOMLINESTRG, 0), MPVOID);
    11821187    WinSendDlgItemMsg(hwnd, CFGC_DIRCOMPARE, EM_SETTEXTLIMIT,
    1183                       MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
     1188                      MPFROM2SHORT(MAXCOMLINESTRG, 0), MPVOID);
    11841189    WinEnableWindow(WinWindowFromID(hwnd, CFGC_FIND), FALSE);
    11851190    PostMsg(hwnd, UM_UNDO, MPVOID, MPVOID);
     
    12571262  case WM_CLOSE:
    12581263    {
    1259       CHAR szBuf[CCHMAXPATH], *psz;
    1260 
    1261       WinQueryDlgItemText(hwnd, CFGC_DIRCOMPARE, CCHMAXPATH, szBuf);
    1262         szBuf[CCHMAXPATH - 1] = 0;
    1263         if (strcmp(szBuf, dircompare)) {
    1264           psz = CheckApp_QuoteAddExe(szBuf);
    1265           memcpy(dircompare, psz, strlen(psz) + 1);
    1266           if (!strchr(dircompare, '%') && strlen(dircompare) > 3)
    1267             strcat(dircompare, " %a");
    1268         }
     1264      CHAR szCLBuf[MAXCOMLINESTRG];
     1265      PSZ psz;
     1266
     1267      psz = xmalloc(MAXCOMLINESTRG, pszSrcFile, __LINE__);
     1268      WinQueryDlgItemText(hwnd, CFGC_DIRCOMPARE, MAXCOMLINESTRG, szCLBuf);
     1269        szCLBuf[MAXCOMLINESTRG - 1] = 0;
     1270        if (strcmp(szCLBuf, dircompare)){
     1271          CheckApp_QuoteAddExe(psz, szCLBuf);
     1272          memcpy(dircompare, psz, strlen(psz) + 1);
     1273          if (!strchr(dircompare, '%') && strlen(dircompare) > 3)
     1274            strcat(dircompare, " %a");
     1275        }
    12691276      PrfWriteProfileString(fmprof, appname, "DirCompare", dircompare);
    1270       WinQueryDlgItemText(hwnd, CFGC_COMPARE, CCHMAXPATH, szBuf);
    1271         szBuf[CCHMAXPATH - 1] = 0;
    1272         if (strcmp(szBuf, compare)) {
    1273           psz = CheckApp_QuoteAddExe(szBuf);
    1274           memcpy(compare, psz, strlen(psz) + 1);
    1275           if (!strchr(compare, '%') && strlen(compare) > 3)
    1276             strcat(compare, " %a");
    1277         }
     1277      WinQueryDlgItemText(hwnd, CFGC_COMPARE, MAXCOMLINESTRG, szCLBuf);
     1278        szCLBuf[MAXCOMLINESTRG - 1] = 0;
     1279        if (strcmp(szCLBuf, compare)){
     1280          CheckApp_QuoteAddExe(psz, szCLBuf);
     1281          memcpy(compare, psz, strlen(psz) + 1);
     1282          if (!strchr(compare, '%') && strlen(compare) > 3)
     1283            strcat(compare, " %a");
     1284        }
    12781285      PrfWriteProfileString(fmprof, appname, "Compare", compare);
    12791286      break;
Note: See TracChangeset for help on using the changeset viewer.