[pacman-dev] [PATCH] Size handling was changed in fgets() functions

Dan McGee dpmcgee at gmail.com
Mon Oct 19 08:41:46 EDT 2009


On Sun, Oct 18, 2009 at 11:39 PM, Laszlo Papp <djszapi at archlinux.us> wrote:
> On Mon, Oct 19, 2009 at 3:35 AM, Dan McGee <dpmcgee at gmail.com> wrote:
>
>> On Sat, Oct 17, 2009 at 4:54 PM, Laszlo Papp <djszapi2 at gmail.com> wrote:
>> > Pacman's fgets function in the API used hardcoded numbers to identify the
>> size.
>> > This is not good practice, so replace them with sizeof handling.
>> >
>> > Signed-off-by: Laszlo Papp <djszapi at archlinux.us>
>> > ---
>>
>> Doesn't apply to git HEAD...
>>
>> dmcgee at galway ~/projects/pacman (master)
>> $ git am -3 -s < /tmp/pacman-sizeof.patch
>> Applying: Size handling was changed in fgets() functions
>> Using index info to reconstruct a base tree...
>> error: patch failed: lib/libalpm/trans.c:320
>> error: lib/libalpm/trans.c: patch does not apply
>> error: patch failed: src/pacman/util.c:580
>> error: src/pacman/util.c: patch does not apply
>> Did you hand edit your patch?
>> It does not apply to blobs recorded in its index.
>> Cannot fall back to three-way merge.
>> Patch failed at 0001 Size handling was changed in fgets() functions
>> When you have resolved this problem run "git am -3 --resolved".
>> If you would prefer to skip this patch, instead run "git am -3 --skip".
>> To restore the original branch and stop patching run "git am -3 --abort".
>>
>>
>>
>>
> I don't know what's the problem by you, but it works here fine with this
> procedure:
>
> git clone git://projects.archlinux.org/pacman.git pacman && cd pacman && git
> checkout -b working && git apply
> 0001-Size-handling-was-changed-in-fgets-functions.patch
>
> Could you check it ? I've attached the patch file.

The "problem by me" is you just sent me two completely different patch
files, one of which was missing necessary spaces along with having
numerous other differences. This one does apply (so thanks), but look
at how different it is- not even close to the same.

-Dan

dmcgee at galway ~/projects/pacman (master)
$ diff -u /tmp/pacman-sizeof.patch
/tmp/0001-Size-handling-was-changed-in-fgets-functions.patch
--- /tmp/pacman-sizeof.patch	2009-10-19 07:39:35.770019492 -0500
+++ /tmp/0001-Size-handling-was-changed-in-fgets-functions.patch	2009-10-18
23:35:13.000000000 -0500
@@ -1,6 +1,7 @@
-From: Laszlo Papp <djszapi2 at gmail.com>
-Date: Sat, 17 Oct 2009 23:54:07 +0200
-Subject: [pacman-dev] [PATCH] Size handling was changed in fgets() functions
+From b9cf40c1d42161055f3293f65fc912f875cc7268 Mon Sep 17 00:00:00 2001
+From: Laszlo Papp <djszapi at archlinux.us>
+Date: Sat, 17 Oct 2009 23:12:19 +0200
+Subject: [PATCH 1/4] Size handling was changed in fgets() functions

 Pacman's fgets function in the API used hardcoded numbers to identify the size.
 This is not good practice, so replace them with sizeof handling.
@@ -22,17 +23,17 @@
  	char line[513];
 +	int	sline = sizeof(line)-1;
  	char *pkgpath = NULL;
-
+
  	ALPM_LOG_FUNC;
 @@ -418,7 +419,7 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info,
pmdbinfrq_t inforeq)
  			info->name, inforeq);
-
+
  	/* clear out 'line', to be certain - and to make valgrind happy */
 -	memset(line, 0, 513);
 +	memset(line, 0, sline+1);
-
+
  	pkgpath = get_pkgpath(db, info);
-
+
 @@ -442,7 +443,7 @@ int _alpm_db_read(pmdb_t *db, pmpkg_t *info,
pmdbinfrq_t inforeq)
  			}
  			_alpm_strtrim(line);
@@ -215,7 +216,7 @@
 @@ -320,7 +320,8 @@ static int grep(const char *fn, const char *needle)
  	}
  	while(!feof(fp)) {
- 		char line[1025];
+ 		char line[1024];
 -		fgets(line, 1024, fp);
 +		int sline = sizeof(line)-1;
 +		fgets(line, sline, fp);
@@ -229,21 +230,20 @@
 @@ -580,6 +580,7 @@ void display_optdepends(pmpkg_t *pkg)
  static int question(short preset, char *fmt, va_list args)
  {
- 	char response[33];
+ 	char response[32];
 +	int sresponse = sizeof(response)-1;
  	FILE *stream;
-
+
  	if(config->noconfirm) {
 @@ -602,7 +603,7 @@ static int question(short preset, char *fmt, va_list args)
  		return(preset);
  	}
-
+
 -	if(fgets(response, 32, stdin)) {
 +	if(fgets(response, sresponse, stdin)) {
  		strtrim(response);
  		if(strlen(response) == 0) {
  			return(preset);
---
+--
 1.6.4.4


More information about the pacman-dev mailing list