[PATCH] Correct problem with initrd.addrsize generation (#546422)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The last write() line was writing out the addr value again instead of
size.  Also include libgen.h for basename() call and lose the char *
we never use from the strtoul() call.
---
 utils/addrsize.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/utils/addrsize.c b/utils/addrsize.c
index 5933a00..f1b1a7d 100644
--- a/utils/addrsize.c
+++ b/utils/addrsize.c
@@ -32,6 +32,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <string.h>
+#include <libgen.h>
 
 int main(int argc,char **argv) {
     char *cmd = basename(argv[0]);
@@ -39,7 +40,6 @@ int main(int argc,char **argv) {
     struct stat initrd_stat;
     unsigned int addr = 0, size = 0, zero = 0;
     int fd, rc;
-    char *tmp = NULL;
     mode_t mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;
 
     if (argc != 4) {
@@ -59,7 +59,7 @@ int main(int argc,char **argv) {
         return 2;
     }
 
-    addr = htonl(strtoul(address, &tmp, 0));
+    addr = htonl(strtoul(address, NULL, 0));
     size = htonl(initrd_stat.st_size);
     fd = open(output, O_CREAT | O_RDWR, mode);
 
@@ -78,7 +78,7 @@ int main(int argc,char **argv) {
         return 5;
     }
 
-    if (write(fd, &addr, sizeof(int)) == -1) {
+    if (write(fd, &size, sizeof(int)) == -1) {
         perror("writing initrd.addr (zero) ");
         return 6;
     }
-- 
1.7.0.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux