Added a few more error checks to the show command.
[egate.git] / kernel / urp.c
index 5b73f46..4a23bb8 100644 (file)
  * Europagate, 1995
  *
  * $Log: urp.c,v $
- * Revision 1.35  1995/05/16 09:40:43  adam
+ * Revision 1.36  1995/05/17 10:51:33  adam
+ * Added a few more error checks to the show command.
+ *
+ * Revision 1.35  1995/05/16  09:40:43  adam
  * LICENSE. Setting of CCL token names (and/or/not/set) in read_kernel_res.
  *
  * Revision 1.34  1995/05/04  10:40:08  adam
@@ -695,7 +698,19 @@ static int exec_show (struct ccl_token *list)
             li = li->next;
         }
         else
+        {
+            int len = li->len;
+            memcpy (tmp_str, li->name, len);
+            tmp_str[len] = '\0';
+            if (atoi(tmp_str) <= 0)
+            {
+                fprintf (reply_fd, "%s\n",
+                         gw_res_get (info.kernel_res, "gw.err.bad.show",
+                                     "Integer expected"));
+                return -3;
+            }
             li = li->next;
+        }
     }
     if (set_token)
         gw_log (GW_LOG_DEBUG, KERNEL_LOG, "Got set=%.*s", set_token->len,
@@ -731,6 +746,15 @@ static int exec_show (struct ccl_token *list)
                     memcpy (tmp_str, li->name, len);
                     tmp_str [len] = '\0';
                     number = atoi (tmp_str) - offset + 1;
+                    if (number <= 0)
+                    {
+                        fprintf (reply_fd, "%s\n",
+                                 gw_res_get (info.kernel_res,
+                                             "gw.err.pos.show",
+                                             "Starting position "
+                                             "greater than ending position"));
+                        return -3;
+                    }
                 }
                 else
                 {
@@ -743,7 +767,7 @@ static int exec_show (struct ccl_token *list)
             }
             li = li->next;
         }
-        else
+        else if (li->kind == CCL_TOK_TERM)
         {
             len = li->len;
             memcpy (tmp_str, li->name, len);
@@ -1103,13 +1127,14 @@ void urp_end (void)
         mta = gw_res_get (info.kernel_res, "gw.reply.mta",
                          "/usr/lib/sendmail");
         sprintf (cmd, "%s %s < %s", mta, info.from_str, info.reply_fname);
-        
+#if 1
         mta_code = system (cmd);
         if (mta_code)
             gw_log (GW_LOG_FATAL, KERNEL_LOG,
                     "Reply '%s' got exit code %d", cmd, mta_code);
        else
             unlink (info.reply_fname);        
+#endif
         gw_log (GW_LOG_ACCT, KERNEL_LOG, "User end %s", info.from_str);
     }
 }