dtcm: Coverity 88675
[oweals/cde.git] / cde / programs / dtsession / SmUI.c
index 94c640d9ef23160aee3a461a33ec7b8d7a75a089..9ea710de9ba3a58305ddddc8abb3e46d45429324 100644 (file)
@@ -16,7 +16,7 @@
  * details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with these librararies and programs; if not, write
+ * License along with these libraries and programs; if not, write
  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  * Floor, Boston, MA 02110-1301 USA
  */
@@ -170,7 +170,7 @@ static Boolean saveTimeout;
 Widget 
 CreateLockDialog( void )
 {
-    int        i;
+  int  i, slen;
     Widget     loginLabel, instructLabel, tmpLock, indFrame;
     Widget     passwdLabel, passwdForm, picFrame, loginPic, loginFrame;
     Dimension  width;          /* width, height of login label    */
@@ -279,10 +279,10 @@ CreateLockDialog( void )
      */
     i = 0;
     envLog = getenv("LOGNAME");
-    lockMessage = XtMalloc(100 + strlen(envLog));
-    sprintf(
-       lockMessage,
-       (char*) GETMESSAGE(18, 1, "Display locked by user %s."), envLog);
+    slen = 100 + strlen(envLog) + 1;
+    lockMessage = XtCalloc(1, slen);
+    snprintf(lockMessage, slen - 1,
+             (char*) GETMESSAGE(18, 1, "Display locked by user %s."), envLog);
     lockString = XmStringCreateLocalized(lockMessage);
     XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
     XtSetArg(uiArgs[i], XmNtopPosition, 20); i++;
@@ -907,9 +907,8 @@ CreateLockDialogWithCover(
      */
     i = 0;
     envLog = getenv("LOGNAME");
-    lockMessage = XtMalloc(100 + strlen(envLog));
-    sprintf(
-       lockMessage,
+    lockMessage = XtCalloc(1, 100 + strlen(envLog));
+    snprintf(lockMessage, 100 + strlen(envLog) - 1,
        ((char *)GETMESSAGE(18, 1, "Display locked by user %s.")), envLog);
     lockString = XmStringCreateLocalized(lockMessage);
     XtSetArg(uiArgs[i], XmNtopAttachment, XmATTACH_POSITION); i++;
@@ -1162,7 +1161,7 @@ ImmediateExit(
      * Turn off SIGTERM so we don't catch one in the middle of shutting
      * down
      */
-#if !defined(SVR4) && !defined(sco)
+#if !defined(SVR4)
     old = sigblock(sigmask(SIGTERM));
     sigblock(sigmask(SIGHUP));
     sigblock(sigmask(SIGPIPE));
@@ -1664,7 +1663,7 @@ SimpleOK(
  *
  *  Description:
  *  -----------
- *  Give the visual feedback neccessary when the user is entering a password
+ *  Give the visual feedback necessary when the user is entering a password
  *
  *
  *  Inputs:
@@ -1686,9 +1685,13 @@ UpdatePasswdField(
         int numChars )
 {
     int i, index;
-    char passwdMessage[25];
+    char *passwdMessage = XtMalloc(numChars + 1);
     XmString tmpString;
 
+    if (!passwdMessage) {
+      PrintErrnoError(DtError, smNLS.cantMallocErrorString);
+      return;
+    }
 
     if(numChars > 0)
     {
@@ -1708,7 +1711,7 @@ UpdatePasswdField(
     }
 
     tmpString = XmStringCreateLocalized (passwdMessage);
-
+    XtFree(passwdMessage);
     /*
      * Set the index for the indLabel widget
      */
@@ -1761,22 +1764,6 @@ WarnNoStartup( void )
     XmString   bmsNoStartString;
     String     tmpString;
 
-#ifdef __osf__
-
-    bmsNoStartString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 76,
-        "The DT messaging system could not be started.\n\n\
-To correct the problem:\n\n\
-1.  Choose [OK] to return to the login screen.\n\n\
-2.  Select Failsafe Session from the login screen's option\n\
-         menu and log in.\n\n\
-3.  Check to see that your hostname exists correctly in /etc/hosts if your\n\
-     network has already been configured.\n\
-4.  If your network has not yet been configured, make sure that /etc/hosts\n\
-     has the following entry in it:\n\
-     127.0.0.1 localhost \n\n\
-For additional information, see the CDE User's Guide.")));
-#else
-
     bmsNoStartString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 36,
         "The desktop messaging system could not be started.\n\n\
 To correct the problem:\n\n\
@@ -1787,7 +1774,6 @@ To correct the problem:\n\n\
         the hostname is correct (/etc/hosts) and that the\n\
         network is properly configured.\n\n\
 For additional information, see the CDE User's Guide.")));
-#endif
 
     /*
      * Now create the dialog box
@@ -1826,93 +1812,6 @@ For additional information, see the CDE User's Guide.")));
     return(0);
 } /* END OF FUNCTION WarnNoStartup */
 
-
-#ifdef __osf__
-
-/*************************************<->*************************************
- *
- *  WarnNewProfile()
- *
- *
- *  Description:
- *  -----------
- *  Warn the user that a new .dtprofile has just been added to their $HOME
- *  directory, indicating a need to edit it and their .login/.profile files.
- *
- *
- *  Inputs:
- *  ------
- *
- * 
- *  Outputs:
- *  -------
- *  None.
- *
- *
- *  Comments:
- *  --------
- * 
- *************************************<->***********************************/
-int 
-WarnNewProfile( void )
-{
-    int       i;
-    XmString  newProfileString;
-    String    tmpString;
-
-    newProfileString = XmStringCreateLocalized(((char *)GETMESSAGE(18, 99,
-   "The new file '.dtprofile' has been added to your home directory.\n\
-\n\
-   Follow the instructions in this file to ensure that when you log in\n\
-   again your '.login' or '.profile' file will be activated and \n\
-   that it will interact correctly with CDE. \n\
-\n\
-   For additional information, see the CDE Advanced User's and System\n\
-   Administrator's Guide.")));
-
-
-    /*
-     * Now create the dialog box
-     */
-    i = 0;
-    tmpString = GETMESSAGE(18, 37, "Action Required");
-    XtSetArg(uiArgs[i], XmNmessageString, newProfileString);i++;
-    XtSetArg(uiArgs[i], XmNallowShellResize, True);  i++;
-    XtSetArg(uiArgs[i], XmNdialogStyle, XmDIALOG_SYSTEM_MODAL); i++;
-    XtSetArg(uiArgs[i], XmNmessageAlignment, XmALIGNMENT_BEGINNING); i++;
-    XtSetArg(uiArgs[i], XmNtitle, tmpString); i++;
-    XtSetArg(uiArgs[i], XmNokLabelString, smDD.okString); i++;
-    XtSetArg(uiArgs[i], XmNautoUnmanage, False); i++;
-    smDD.newProfile = XmCreateWarningDialog(smGD.topLevelWid, 
-                                           "newProfileDialog",
-                                           uiArgs, i);
-
-    XtSetArg(uiArgs[i], XmNuseAsyncGeometry, True);i++;
-    XtSetValues(XtParent(smDD.newProfile), uiArgs, i);
-
-    XtAddCallback (XtParent(smDD.newProfile),
-                  XmNpopupCallback, DialogUp, NULL);
-    XtUnmanageChild(XmMessageBoxGetChild(smDD.newProfile,
-                                        XmDIALOG_HELP_BUTTON));
-    XtUnmanageChild(XmMessageBoxGetChild(smDD.newProfile,
-                                        XmDIALOG_CANCEL_BUTTON));
-
-    /*
-     * Now add in the callback and get out of here
-     */
-    XtAddCallback (smDD.newProfile, XmNokCallback,
-                  SimpleOK, smDD.newProfile);
-    XmStringFree(newProfileString);
-
-    XtManageChild(smDD.newProfile);
-
-    return(0);
-} /* END OF FUNCTION WarnNewProfile */
-
-
-#endif
-
-
 /*************************************<->*************************************
  *
  *  ConfirmSessionCreation () -