php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57268 rar_open does not return a valid rar resource on Win32
Submitted: 2006-09-30 17:17 UTC Modified: 2009-11-28 22:44 UTC
From: xdb_sharing at hotmail dot com Assigned:
Status: Closed Package: rar (PECL)
PHP Version: 5.1.4 OS: Microsoft Windows XP Build 2600
Private report: No CVE-ID: None
 [2006-09-30 17:17 UTC] xdb_sharing at hotmail dot com
Description:
------------
When im using the rar_open() function on a Win32 based system, ill dont get a valid resource back. I've used gettype() to get the type of a returned type. but it only gives me null.

Reproduce code:
---------------
<?php
	$rar = rar_open('archive.rar');
	rar_close($rar);
?>

Expected result:
----------------
No output expected (Error clean)

Actual result:
--------------
Warning: rar_close(): supplied argument is not a valid Rar resource in C:\Webserver\www\rar.php on line 3

Warning: rar_close() [function.rar-close]: cannot find Rar file resource in C:\Webserver\www\rar.php on line 3

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-30 17:18 UTC] xdb_sharing at hotmail dot com
Forgot to add, im using version 0.3.1 of the RAR DLL =)
 [2006-10-02 04:38 UTC] tony2001 at phpclub dot net
This means the "archive.rar" not found or is not readable.
I've already added an error message to indicate that in CVS.
 [2009-11-19 00:43 UTC] glopes at nebm dot ist dot utl dot pt
This was actually a bug. The open failed because the path was relative to apache's server root, not the script directory. Fixed in revision #290966.
 [2009-11-20 11:15 UTC] carsten_sttgt at gmx dot de
Hi Gustavo,

> Fixed in revision #290966.

In #290966 you have introduced strnlen(). Well, on VC6 I don't have strnlen() and so I can't build the current runk (and I must stick with #290965).

Regards,
Carsten
 [2009-11-23 04:06 UTC] tony at daylessday dot org
Reopen.
 [2009-11-24 12:54 UTC] carsten_sttgt at gmx dot de
An update:

a) as of revision #291126 you are using a .c, and so I can add a piece of code from "php_src/main/spprintf.c", and I can compile php_rar again :-)

b) as of revision # 291221 does not compile:-/ Well, with a small change this is fixable.

Regards,
Carsten (cwiedmann)

(BTW: Sorry, can't upload a file while making a comment)

Index: rar.c
===================================================================
--- rar.c	(Revision 291275)
+++ rar.c	(Arbeitskopie)
@@ -85,6 +85,13 @@
 }
 /* }}} */
 
+#if !HAVE_STRNLEN
+static size_t strnlen(const char *s, size_t maxlen) {
+	char *r = memchr(s, '\0', maxlen);
+	return r ? r-s : maxlen;
+}
+#endif
+
 /* WARNING: It's the caller who must close the archive.
  * Kind of against the conventions */
 int _rar_find_file(struct RAROpenArchiveDataEx *open_data, /* IN */
@@ -345,8 +352,8 @@
 									 const wchar_t * const file, //can be NULL
 									 zval *target TSRMLS_DC) /* {{{ */
 {
-	const wchar_t last_name[1024] = {};
-	const char strict_last_name[1024] = {};
+	const wchar_t last_name[1024];
+	const char strict_last_name[1024];
 	unsigned long packed_size = 0UL;
 	struct RARHeaderDataEx *last_entry;
 	int any_commit = FALSE;
 [2009-11-28 20:10 UTC] glopes at nebm dot ist dot utl dot pt
That const wchar_t last_name[1024] = {} was dumb... The const must be dropped. I had actually forgotten to compile that revision before commiting.

Anyway, I'm doing some refactoring, but I cannot guarantee clean builds in VC6 since I don't own it.

I'll try to avoid strnlen. Please continue to report any errors you may find.
 [2009-11-28 22:44 UTC] glopes at nebm dot ist dot utl dot pt
strnlen problem should be fixed in revision #291411.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Jan 17 21:01:24 2020 UTC