Hi,

if there are newlines in directory- or filenames the output-format of the isoinfo -l breaks. Example:


Directory listing of /
       275 dr-xr-xr-x   3    0    0       2048 Aug 21 2018 [    275 02] .
       275 dr-xr-xr-x   3    0    0       2048 Aug 21 2018 [    275 02] ..
280 -r--r--r-- 1 0 0 6144 Aug 16 2018 [ 280 00] file_with_newline 283 -r--r--r-- 1 0 0 21 Aug 13 2018 [ 283 00] file_does_not_exist


It seems that there are two files. But it is only one with the name "file_with_newline\n 283 -r--r--r-- 1 0 0 21 Aug 13 2018 [ 283 00] file_does_not_exist". I replaced the newline with \n in this example.

The following patch introduces a backslash as escape character, so that newlines in directories or filenames are displayed as \n. Backslashes are displayed as \\:


--- mkisofs/diag/isoinfo.c.org  2018-09-10 14:47:44.591623840 +0200
+++ mkisofs/diag/isoinfo.c      2018-09-12 08:09:39.378615018 +0200
@@ -168,6 +168,7 @@
 LOCAL struct stat      fstat_buf;
 LOCAL int              found_rr;
 LOCAL char             name_buf[256*3];
+LOCAL char             name_buf_esc[256*3*2];
 LOCAL char             xname[8192];
 LOCAL unsigned char    date_buf[9];    /* iso_directory_record.date[7] */
 /*
@@ -731,6 +732,29 @@
                                "Aug", "Sep", "Oct", "Nov", "Dec"};

 /*
+ * str_esc must point to a field with a size: sizeof(str)*2
+ */
+LOCAL void
+esc_newlines(str_buf, str_buf_esc)
+char                           *str_buf;
+char                           *str_buf_esc;
+{
+       int i, j;
+       for (i = 0, j = 0; i < strlen(str_buf); i++, j++) {
+               if (str_buf[i] == '\n') {
+                       str_buf_esc[j++] = '\\';
+                       str_buf_esc[j] = 'n';
+               } else if (str_buf[i] == '\\') {
+                       str_buf_esc[j++] = '\\';
+                       str_buf_esc[j] = '\\';
+               } else {
+                       str_buf_esc[j] = str_buf[i];
+               }
+       }
+       str_buf_esc[j] = '\0';
+}
+
+/*
  * Return TRUE if this file was "selected" either based on find rules
  * or for all files if there was no find rule.
  */
@@ -830,7 +854,8 @@
                if (outline[i] == 0) outline[i] = ' ';
        }
        outline[off] = 0;
-       printf("%s %s %s\n", outline, name_buf, xname);
+       esc_newlines(&name_buf, &name_buf_esc);
+       printf("%s %s %s\n", outline, name_buf_esc, xname);
        return (TRUE);
 }

@@ -1163,6 +1188,7 @@
        struct stat                     dstat;
        unsigned char   cl_buffer[2048];
        unsigned char   flags = 0;
+       char    *rootname_esc = 0;
        Llong           size = 0;
        int             sextent = 0;
        int     rlen;
@@ -1172,10 +1198,13 @@
 static int     nlen = 0;


-       if (do_listing && (!do_find || !find_print))
-               printf(_("\nDirectory listing of %s\n"), rootname);
-
        rlen = strlen(rootname);
+       if (do_listing && (!do_find || !find_print)) {
+               rootname_esc = (char *) malloc(rlen*2 + 1);
+               esc_newlines(rootname, rootname_esc);
+               printf(_("\nDirectory listing of %s\n"), rootname_esc);
+               free(rootname_esc);
+       }

        while (len > 0) {
 #ifdef USE_SCG


Best regards,
Lutz Lümken

--
Lutz Lümken                                luem...@pre-sense.de
PRESENSE Technologies GmbH            Sachsenstr. 5, D-20097 HH
Geschäftsführer/Managing Directors       AG Hamburg, HRB 107844
Till Dörges, Jürgen Sander               USt-IdNr.: DE263765024

Wir sind auf der it-sa: 9.-11.10.2018    www.pre-sense.de/it-sa

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
Cdrtools-developers mailing list
Cdrtools-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdrtools-developers

Reply via email to