| 
 | 
Mike... This patch is what I'm using (at the moment) it probably could be done better, but maybe its a start... :) Just do: cd tn5250/src patch < lp5250d.patch Thanks! On Wed, 3 May 2000, Mike Madore wrote: > Hi, > > > Perhaps these parameters should be allocated with malloc(), based on > > the size of the arguments, so that we don't have this type of overflow? > > I could write up a patch if you'd like... > > Definately. I'll put it on ny TODO list. > > Mike >
--- lp5250d.orig        Wed May  3 16:30:08 2000
+++ lp5250d.c   Wed May  3 16:51:27 2000
@@ -42,16 +42,16 @@
 Tn5250PrintSession *printsess = NULL;
 Tn5250Stream *stream = NULL;
 
-char remotehost[20];
-char sessionname[20];
-char transformname[20];
-char outputcommand[30];
-char *mapname = "37";
-char logname[20] = "";
+char *remotehost = NULL;
+char *sessionname = NULL;
+char *transformname = NULL;
+char *outputcommand = NULL;
+char *mapname = NULL;
+char *logname = NULL;
 
 int main(int argc, char *argv[])
 {
-   
+
 
    if (parse_options(argc, argv) < 0)
       syntax();
@@ -105,27 +105,35 @@
 static int parse_options(int argc, char *argv[])
 {
    int arg;
+
+   logname = outputcommand = sessionname = transformname = remotehost = "\0";
+   mapname = "37";
    
    while ((arg = getopt(argc, argv, "t:m:s:T:P:Vwy:")) != EOF) {
       switch (arg) {
 #ifndef NDEBUG
       case 't':
+         logname = malloc(strlen(optarg)+1);
          strcpy(logname,optarg);
          break;
 #endif         
       case 'm':
+         mapname = malloc(strlen(optarg)+1);
         mapname = optarg;
         break;
 
       case 'P':
+         outputcommand = malloc(strlen(optarg)+1);
         strcpy(outputcommand,optarg);
         break;
 
       case 's':
+         sessionname = malloc(strlen(optarg)+1);
         strcpy(sessionname,optarg);
         break;
 
       case 'T':
+         transformname = malloc(strlen(optarg)+1);
         strcpy(transformname,optarg);
         break;
 
@@ -141,6 +149,7 @@
 
    if (optind >= argc)
       return -1;
+   remotehost = malloc(strlen(argv[optind])+1);
    strcpy(remotehost,argv[optind++]);
    if (optind != argc)
       return -1;
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.