42d3218
Patch by Guillem Jover <guillem@debian.org> for arj <= 3.10.22, which
42d3218
fixes format security errors.
42d3218
42d3218
---
42d3218
 arj_arcv.c |   12 ++++++------
42d3218
 arj_user.c |    8 ++++----
42d3218
 arjdisp.c  |   58 ++++++++++++++++++++++++++++------------------------------
42d3218
 arjsfx.c   |    2 +-
42d3218
 fardata.c  |   10 +++++-----
42d3218
 rearj.c    |    2 +-
42d3218
 register.c |    2 +-
42d3218
 7 files changed, 46 insertions(+), 48 deletions(-)
42d3218
42d3218
--- a/fardata.c
42d3218
+++ b/fardata.c
42d3218
@@ -52,7 +52,7 @@ int error_proc(FMSG *errmsg, ...)
42d3218
   /* Check if the message could have a standard error code */
42d3218
   if(errno!=0&&is_std_error(errmsg))
42d3218
   {
42d3218
-   msg_cprintf(0, lf);
42d3218
+   msg_cprintf(0, "\n");
42d3218
    error_report();
42d3218
   }
42d3218
  #endif
42d3218
@@ -379,10 +379,10 @@ static void flush_cbuf(int ccode, char *
42d3218
     {
42d3218
      #if SFX_LEVEL>=ARJSFXV
42d3218
       fprintf(new_stdout, strform, n_text);
42d3218
-      fprintf(new_stdout, lf);
42d3218
+      fprintf(new_stdout, "\n");
42d3218
      #else
42d3218
       printf(strform, n_text);
42d3218
-      printf(lf);
42d3218
+      printf("\n");
42d3218
      #endif
42d3218
     }
42d3218
     else
42d3218
@@ -393,13 +393,13 @@ static void flush_cbuf(int ccode, char *
42d3218
      #ifdef NEED_CRLF
42d3218
       scr_out("\r");
42d3218
      #endif
42d3218
-     scr_out(lf);
42d3218
+     scr_out("\n");
42d3218
     }
42d3218
     if(!no_colors)
42d3218
      textcolor(color_table[ccode&H_COLORMASK].color);
42d3218
    #else
42d3218
     printf(strform, n_text);
42d3218
-    printf(lf);
42d3218
+    printf("\n");
42d3218
    #endif
42d3218
    n_text=t_text+1;
42d3218
    #if SFX_LEVEL>=ARJ
42d3218
--- a/arj_user.c
42d3218
+++ b/arj_user.c
42d3218
@@ -1059,7 +1059,7 @@ static void finish_processing(int cmd)
42d3218
      if(recover_file(tmp_archive_name, nullstr, tmp_tmp_filename, protected, eof_pos))
42d3218
      {
42d3218
       msg_cprintf(H_HL, M_CANT_FIND_DAMAGE, archive_name);
42d3218
-      printf(lf);
42d3218
+      printf("\n");
42d3218
      }
42d3218
      else
42d3218
      {
42d3218
@@ -1294,7 +1294,7 @@ static void finish_processing(int cmd)
42d3218
    if(recover_file(archive_name, nullstr, nullstr, protected, eof_pos))
42d3218
    {
42d3218
     msg_cprintf(H_HL, M_CANT_FIND_DAMAGE, archive_name);
42d3218
-    printf(lf);
42d3218
+    printf("\n");
42d3218
    }
42d3218
    else
42d3218
    {
42d3218
@@ -1327,7 +1327,7 @@ static void finish_processing(int cmd)
42d3218
     msg_cprintf(0, M_CHAPTERS_ON);
42d3218
    else if(chapter_mode==CHAP_REMOVE)
42d3218
     msg_cprintf(0, M_CHAPTERS_OFF);
42d3218
-   msg_cprintf(0, strform, lf);
42d3218
+   msg_cprintf(0, strform, "\n");
42d3218
   }
42d3218
   if(cmd==ARJ_CMD_COPY&&protfile_option&&!arjprot_tail)
42d3218
    msg_cprintf(0, M_ARJPROT_DISABLED);
42d3218
@@ -2303,7 +2303,7 @@ void process_archive()
42d3218
   timestamp_to_str(timetext, &ftime_stamp);
42d3218
   msg_cprintf(H_HL|H_NFMT, M_ARCHIVE_CREATED, timetext);
42d3218
   if(show_ansi_comments)
42d3218
-   printf(cmt_ptr);
42d3218
+   fputs(cmt_ptr, stdout);
42d3218
   else
42d3218
    display_comment(cmt_ptr);
42d3218
   /* The sfx_setup() occurs here */
42d3218
--- a/arj_arcv.c
42d3218
+++ b/arj_arcv.c
42d3218
@@ -913,13 +913,13 @@ int supply_comment(char *cmtname, char *
42d3218
     else
42d3218
     {
42d3218
      strcat(tmp_comment, tmp_cmtline);
42d3218
-     strcat(tmp_comment, lf);
42d3218
+     strcat(tmp_comment, "\n");
42d3218
     }
42d3218
    }
42d3218
    else
42d3218
    {
42d3218
     strcat(tmp_comment, tmp_cmtline);
42d3218
-    strcat(tmp_comment, lf);
42d3218
+    strcat(tmp_comment, "\n");
42d3218
    }
42d3218
   }
42d3218
  }
42d3218
@@ -1846,7 +1846,7 @@ int pack_file(int is_update, int is_repl
42d3218
    raw_eh=eh_lookup(eh, UXSPECIAL_ID)->raw;
42d3218
    uxspecial_stats(raw_eh, UXSTATS_SHORT);
42d3218
   }
42d3218
-  msg_cprintf(0, lf);
42d3218
+  msg_cprintf(0, "\n");
42d3218
  }
42d3218
  if(err_id==0&&user_wants_fail)
42d3218
  {
42d3218
@@ -2523,9 +2523,9 @@ int unpack_validation()
42d3218
    {
42d3218
     msg_cprintf(0, (FMSG *)strform, misc_buf);
42d3218
     if(search_mode==SEARCH_DEFAULT)
42d3218
-     msg_cprintf(0, (FMSG *)lf);
42d3218
+     msg_cprintf(0, "\n");
42d3218
     if(search_mode==SEARCH_BRIEF)
42d3218
-     msg_cprintf(0, (FMSG *)cr);
42d3218
+     msg_cprintf(0, "\r");
42d3218
    }
42d3218
    for(pattern=0; pattern
42d3218
    reserve_size=0;
42d3218
@@ -3652,7 +3652,7 @@ void archive_cleanup()
42d3218
  {
42d3218
   if(msg_fprintf(idxstream, M_TESTING, archive_name)<0)
42d3218
    error(M_DISK_FULL);
42d3218
-  if(fprintf(idxstream, lf)<0)
42d3218
+  if(fprintf(idxstream, "\n")<0)
42d3218
    error(M_DISK_FULL);
42d3218
  }
42d3218
  cmd_verb=ARJ_CMD_TEST;
42d3218
--- a/arjsfx.c
42d3218
+++ b/arjsfx.c
42d3218
@@ -214,7 +214,7 @@ static void final_cleanup(void)
42d3218
   freopen(dev_con, m_w, stdout);
42d3218
  #if SFX_LEVEL>=ARJSFXV
42d3218
   if(ferror(stdout))
42d3218
-   msg_fprintf(stderr, M_DISK_FULL);
42d3218
+   msg_fprintf(stderr, "Can't write file. Disk full?");
42d3218
   if(debug_enabled&&strchr(debug_opt, 't')!=NULL)
42d3218
   {
42d3218
    ticks=get_ticks()-ticks;
42d3218
--- a/rearj.c
42d3218
+++ b/rearj.c
42d3218
@@ -935,7 +935,7 @@ static int convert_archive(char *name)
42d3218
  msg_cprintf(H_HL|H_NFMT, M_OLD_SIZE, old_fsize);
42d3218
  msg_cprintf(H_HL|H_NFMT, M_NEW_SIZE, new_fsize);
42d3218
  msg_cprintf(H_HL|H_NFMT, M_SAVINGS_SIZE, gain);
42d3218
- printf(lf);
42d3218
+ printf("\n");
42d3218
  total_old_fsize+=old_fsize;
42d3218
  total_new_fsize+=new_fsize;
42d3218
  total_files++;
42d3218
--- a/register.c
42d3218
+++ b/register.c
42d3218
@@ -205,7 +205,7 @@ int main(int argc, char **argv)
42d3218
  char reg_source[200];
42d3218
  int i;
42d3218
 
42d3218
- printf(M_REGISTER_BANNER);
42d3218
+ fputs(M_REGISTER_BANNER, stdout);
42d3218
  integrity_pattern[0]--;
42d3218
  build_crc32_table();
42d3218
  if(argc!=2)
42d3218
--- a/arjdisp.c
42d3218
+++ b/arjdisp.c
42d3218
@@ -20,8 +20,6 @@ static long bytes;
42d3218
 static long compsize;
42d3218
 static char cmd_verb;
42d3218
 static char msg_lf[]="\n";
42d3218
-char strform[]="%s";                    /* Export it for scrnio.c, too
42d3218
-                                           (a byte saved is a byte gained) */
42d3218
 
42d3218
 /* Pseudographical controls */
42d3218
 
42d3218
@@ -54,19 +52,19 @@ static void show_init_scrn()
42d3218
  textcolor(7);
42d3218
  clrscr();
42d3218
  gotoxy(2, 2);
42d3218
- scrprintf(win_top);
42d3218
+ fputs(win_top, stdout);
42d3218
  for(i=3; i<24; i++)
42d3218
  {
42d3218
-  gotoxy(2, i); scrprintf(win_border);
42d3218
-  gotoxy(79, i); scrprintf(win_border);
42d3218
+  gotoxy(2, i); fputs(win_border, stdout);
42d3218
+  gotoxy(79, i); fputs(win_border, stdout);
42d3218
  }
42d3218
- gotoxy(2, 24); scrprintf(win_bottom);
42d3218
+ gotoxy(2, 24); fputs(win_bottom, stdout);
42d3218
  gotoxy(10, 5);
42d3218
- scrprintf(M_ARJDISP_COPYRIGHT);
42d3218
+ fputs(M_ARJDISP_COPYRIGHT, stdout);
42d3218
  gotoxy(10, 6);
42d3218
- scrprintf(M_ARJDISP_DISTRIBUTION);
42d3218
+ fputs(M_ARJDISP_DISTRIBUTION, stdout);
42d3218
  gotoxy(10, 7);
42d3218
- scrprintf(M_ARJDISP_LICENSE);
42d3218
+ fputs(M_ARJDISP_LICENSE, stdout);
42d3218
  gotoxy(16, 10);
42d3218
  scrprintf(M_PROCESSING_ARCHIVE, archive_name);
42d3218
  t=strtok(M_ARJDISP_INFO, msg_lf);
42d3218
@@ -74,11 +72,11 @@ static void show_init_scrn()
42d3218
  while(t!=NULL&&i<=23)
42d3218
  {
42d3218
   gotoxy(10, i++);
42d3218
-  scrprintf(strform, t);
42d3218
+  scrprintf("%s", t);
42d3218
   t=strtok(NULL, msg_lf);
42d3218
  }
42d3218
  gotoxy(16, 20);
42d3218
- scrprintf(M_PRESS_ANY_KEY);
42d3218
+ fputs(M_PRESS_ANY_KEY, stdout);
42d3218
  uni_getch();
42d3218
  gotoxy(1, 24);
42d3218
 }
42d3218
@@ -96,19 +94,19 @@ static void show_proc_scrn()
42d3218
  {
42d3218
   clrscr();
42d3218
   gotoxy(2, 2);
42d3218
-  scrprintf(win_top);
42d3218
+  fputs(win_top, stdout);
42d3218
   for(i=3; i<24; i++)
42d3218
   {
42d3218
-   gotoxy(2, i); scrprintf(win_border);
42d3218
-   gotoxy(79, i); scrprintf(win_border);
42d3218
+   gotoxy(2, i); fputs(win_border, stdout);
42d3218
+   gotoxy(79, i); fputs(win_border, stdout);
42d3218
   }
42d3218
-  gotoxy(2, 24); scrprintf(win_bottom);
42d3218
+  gotoxy(2, 24); fputs(win_bottom, stdout);
42d3218
   gotoxy(10, 5);
42d3218
-  scrprintf(M_ARJDISP_COPYRIGHT);
42d3218
+  fputs(M_ARJDISP_COPYRIGHT, stdout);
42d3218
   gotoxy(10, 6);
42d3218
-  scrprintf(M_ARJDISP_DISTRIBUTION);
42d3218
+  fputs(M_ARJDISP_DISTRIBUTION, stdout);
42d3218
   gotoxy(10, 7);
42d3218
-  scrprintf(M_ARJDISP_LICENSE);
42d3218
+  fputs(M_ARJDISP_LICENSE, stdout);
42d3218
   gotoxy(16, 10);
42d3218
   scrprintf(M_PROCESSING_ARCHIVE, archive_name);
42d3218
   gotoxy(16, 12);
42d3218
@@ -132,13 +130,13 @@ static void show_proc_scrn()
42d3218
     break;
42d3218
   }
42d3218
   gotoxy(15, 14);
42d3218
-  scrprintf(ind_top);
42d3218
+  fputs(ind_top, stdout);
42d3218
   gotoxy(15, 15);
42d3218
-  scrprintf(ind_middle);
42d3218
+  fputs(ind_middle, stdout);
42d3218
   gotoxy(15, 16);
42d3218
-  scrprintf(ind_bottom);
42d3218
+  fputs(ind_bottom, stdout);
42d3218
   gotoxy(16, 18);
42d3218
-  scrprintf(M_ARJDISP_CTR_START);
42d3218
+  fputs(M_ARJDISP_CTR_START, stdout);
42d3218
  }
42d3218
  else
42d3218
  {
42d3218
@@ -146,7 +144,7 @@ static void show_proc_scrn()
42d3218
   gotoxy(16, 15);
42d3218
   memset(progress, indo, i);
42d3218
   progress[i]='\0';
42d3218
-  scrprintf(progress);
42d3218
+  fputs(progress, stdout);
42d3218
   gotoxy(16, 18);
42d3218
   scrprintf(M_ARJDISP_CTR, calc_percentage(bytes, uncompsize)/10);
42d3218
  }
42d3218
@@ -165,19 +163,19 @@ static void show_ending_scrn()
42d3218
  textcolor(7);
42d3218
  clrscr();
42d3218
  gotoxy(2, 2);
42d3218
- scrprintf(win_top);
42d3218
+ fputs(win_top, stdout);
42d3218
  for(i=3; i<24; i++)
42d3218
  {
42d3218
-  gotoxy(2, i); scrprintf(win_border);
42d3218
-  gotoxy(79, i); scrprintf(win_border);
42d3218
+  gotoxy(2, i); fputs(win_border, stdout);
42d3218
+  gotoxy(79, i); fputs(win_border, stdout);
42d3218
  }
42d3218
- gotoxy(2, 24); scrprintf(win_bottom);
42d3218
+ gotoxy(2, 24); fputs(win_bottom, stdout);
42d3218
  gotoxy(10, 5);
42d3218
- scrprintf(M_ARJDISP_COPYRIGHT);
42d3218
+ fputs(M_ARJDISP_COPYRIGHT, stdout);
42d3218
  gotoxy(10, 6);
42d3218
- scrprintf(M_ARJDISP_DISTRIBUTION);
42d3218
+ fputs(M_ARJDISP_DISTRIBUTION, stdout);
42d3218
  gotoxy(10, 7);
42d3218
- scrprintf(M_ARJDISP_LICENSE);
42d3218
+ fputs(M_ARJDISP_LICENSE, stdout);
42d3218
  gotoxy(16, 10);
42d3218
  scrprintf(M_FINISHED_PROCESSING, archive_name);
42d3218
  gotoxy(1, 24);