diff options
author | Helge Deller <deller@gmx.de> | 2014-04-16 20:45:27 +0200 |
---|---|---|
committer | Helge Deller <deller@gmx.de> | 2014-04-16 20:45:27 +0200 |
commit | f4dfa2d330f56577d811350e416322cf0f28c18b (patch) | |
tree | ad3490a4dbe28ab860cc156bd1317cbf82956ddc | |
parent | f89ac963192b24e7e581f8b45e4326571248b4be (diff) | |
download | palo-f4dfa2d330f56577d811350e416322cf0f28c18b.tar.gz |
Fix checks and docu for kernel command line length
We allow a maximum of 1023 characters for the kernel command line
since quite some time already, but the runtime checks and the
documentation didn't reflected that change yet.
-rw-r--r-- | palo.conf | 2 | ||||
-rw-r--r-- | palo/palo.c | 18 | ||||
-rw-r--r-- | palo/usage.txt | 2 |
3 files changed, 11 insertions, 11 deletions
@@ -15,7 +15,7 @@ # (if an option is repeated, the last instance of it takes precedence) # -?, --help Print this information # -c, --commandline=default kernel command line -# Maximum 127 characters. +# Maximum 1023 characters. # -k, --recoverykernel=path to recovery kernel (perhaps /boot/vmlinux) # -b, --bootloader=path to boot loader Defaults to /usr/share/palo/iplboot -- you usually don't diff --git a/palo/palo.c b/palo/palo.c index 0698717..0638d14 100644 --- a/palo/palo.c +++ b/palo/palo.c @@ -151,7 +151,7 @@ check_bootloader(int media, int line) B32(f.kern32_offset), B32(f.kern32_sz), B32(f.kern32_native_sz), B32(f.kern64_offset), B32(f.kern64_sz), B32(f.kern64_native_sz), B32(f.rd_offset), B32(f.rd_sz), - f.cmdline); + f.cmdline[0] ? f.cmdline : f.cmdline_old); #endif return 1; @@ -307,7 +307,7 @@ do_sequential(int media, int kernel32, int kernel64, where += write(media, &f, FW_BLOCKSIZE - (where % FW_BLOCKSIZE)); if (commandline != 0) - strcpy(f.cmdline, commandline); + strncpy(f.cmdline, commandline, sizeof(f.cmdline)-1); STRUCTWRITE(media, f, 0); @@ -427,7 +427,7 @@ do_cdrom(int media, int kernel32, int kernel64, } if (commandline != 0) - strcpy(f.cmdline, commandline); + strncpy(f.cmdline, commandline, sizeof(f.cmdline)-1); STRUCTWRITE(media, f, 0); @@ -523,7 +523,7 @@ do_formatted(int init, int media, const char *medianame, int partition, f.flags |= PFLAG_EXT2; if(commandline) - strncpy(f.cmdline, commandline, sizeof(f.cmdline)); + strncpy(f.cmdline, commandline, sizeof(f.cmdline)-1); write_bootloader(media, bootloaderfd, holestart, holestart + EXT2_HOLE*EXT2_BLOCKSIZE, &f); @@ -544,7 +544,7 @@ do_formatted(int init, int media, const char *medianame, int partition, } if(commandline) - strncpy(f.cmdline, commandline, sizeof(f.cmdline)); + strncpy(f.cmdline, commandline, sizeof(f.cmdline)-1); write_bootloader(media, bootloaderfd, f.ipl_addr, f.ipl_addr + EXT2_HOLE*EXT2_BLOCKSIZE, &f); @@ -621,7 +621,7 @@ do_randomaccess(int init, int media, int kernel32, int kernel64, where = write_ramdisk(media, ramdisk, where, end, &f); if (commandline != 0) - strcpy(f.cmdline, commandline); + strncpy(f.cmdline, commandline, sizeof(f.cmdline)-1); STRUCTWRITE(media, f, 0); } @@ -661,7 +661,7 @@ do_randomaccess(int init, int media, int kernel32, int kernel64, } if (commandline != 0) - strcpy(f.cmdline, commandline); + strncpy(f.cmdline, commandline, sizeof(f.cmdline)-1); STRUCTWRITE(media, f, 0); #endif @@ -852,8 +852,8 @@ main(int argc, char *argv[]) break; case 'c': commandline = optarg; - if (strlen(commandline) > 127) - error(3,127,strlen(commandline)); + if (strlen(commandline) >= CMDLINELEN) + error(3,CMDLINELEN-1,strlen(commandline)); break; case 'e': if(strcmp(optarg, "2") == 0) diff --git a/palo/usage.txt b/palo/usage.txt index ec6c474..a0f9dee 100644 --- a/palo/usage.txt +++ b/palo/usage.txt @@ -2,7 +2,7 @@ Usage: palo [options] (if an option is repeated, the last instance of it takes precedence) -?, --help Print this information -c, --commandline=default kernel command line - Maximum 127 characters. + Maximum 1023 characters. -k, --recoverykernel=path to recovery kernel (perhaps /boot/vmlinux) -b, --bootloader=path to boot loader (usually /usr/share/palo/iplboot) -r, --ramdisk=path to initial ramdisk image |