[oe-commits] Andrea Adami : kexec-tools_2.0.1: rework/fix no-getline-no-fscanf.patch. Credits to Yuri Bushmelev.

git version control git at git.openembedded.org
Wed Oct 7 20:42:58 UTC 2009


Module: openembedded.git
Branch: org.openembedded.dev
Commit: f5d88d0f924e52828a70e7390b0c460f0f3b59bb
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=f5d88d0f924e52828a70e7390b0c460f0f3b59bb

Author: Andrea Adami <andrea.adami at gmail.com>
Date:   Wed Oct  7 22:39:33 2009 +0200

kexec-tools_2.0.1: rework/fix no-getline-no-fscanf.patch. Credits to Yuri Bushmelev.

---

 recipes/kexec/files/no-getline-no-fscanf.patch |   35 +++++++++++++++--------
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/recipes/kexec/files/no-getline-no-fscanf.patch b/recipes/kexec/files/no-getline-no-fscanf.patch
index d2b803c..f2a32b4 100644
--- a/recipes/kexec/files/no-getline-no-fscanf.patch
+++ b/recipes/kexec/files/no-getline-no-fscanf.patch
@@ -1,33 +1,44 @@
 Index: kexec-tools-2.0.1/kexec/kexec.c
 ===================================================================
 --- kexec-tools-2.0.1.orig/kexec/kexec.c	2008-02-24 14:15:46.950825917 +0100
-+++ kexec-tools-2.0.1/kexec/kexec.c	2009-10-06 00:37:01.000000000 +0200
-@@ -932,14 +932,22 @@
- }
++++ kexec-tools-2.0.1/kexec/kexec.c	2009-10-07 22:30:58.000000000 +0200
+@@ -933,15 +933,32 @@
 
  static int kexec_loaded(void)
  {
 -	int ret;
-+	int ret = 0;
++	long ret = -1;
 	FILE *fp;
-+	char *endptr;
-+	char *line[3];
++	char *p;
++	char line[3];
 
 	fp = fopen("/sys/kernel/kexec_loaded", "r");
 	if (fp == NULL)
 		return -1;
 -	fscanf(fp, "%d", &ret);
 +/*	fscanf(fp, "%d", &ret); */
++	p = fgets(line, sizeof(line), fp);
+	fclose(fp);
+-	return ret;
 +
-+	if ( NULL == fgets(line, sizeof(line), fp) ) {
++	if ( NULL == p)
 +		return -1;
-+	ret = strtol(line, &endptr, 10);
-+	}
 +
-	fclose(fp);
-	return ret;
++	ret = strtol(line, &p, 10);
++
++	if (ret > INT_MAX)
++	/* Too long */
++		return -1;
++
++	if (p == line)
++	/* No digits were found */
++		return -1;
++
++	return (int)ret;
  }
-@@ -989,17 +997,22 @@
+
+ /*
+@@ -989,18 +1006,23 @@
  char *get_command_line(void)
  {
 	FILE *fp;





More information about the Openembedded-commits mailing list