{"thread":{"id":"15757","subject":"[PATCH (BUGFIX)] gitweb: Fix two 'uninitialized value' varnings in git_tree()","startedAt":"2008-10-02T14:50:04Z","lastAt":"2008-10-02T15:08:59Z","messageCount":3,"participants":["Jakub Narebski","Giuseppe Bilotta","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"92170","messageId":"20081002144602.19247.4434.stgit@localhost.localdomain","threadId":"15757","inReplyTo":null,"subject":"[PATCH (BUGFIX)] gitweb: Fix two 'uninitialized value' varnings in git_tree()","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-10-02T14:50:04Z","receivedAt":"2008-10-02T14:50:04Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"If we did try to access nonexistent directory or file, which means\nthat git_get_hash_by_path() returns `undef`, uninitialized $hash\nvariable was passed to 'open' call.  Now we fail early with \"404 Not\nFound - No such tree\" error.  (If we try to access something which\ndoes not resolve to tree-ish, for example a file / 'blob' object, the\nerror will be caught later, as \"404 Not Found - Reading tree failed\"\nerror).\n\nIf we tried to use 'tree' action without $file_name ('f' parameter)\nset, which means either tree given by hash or a top tree (and we\ncurrently cannot distinguish between those two cases), we cannot print\npath breadcrumbs with git_print_page_path().  Fix this by moving call\nto git_print_page_path() inside conditional.\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nThose two errors were discovered when creating new basic test for\npath_info (following). \n\nI was also thinking about alternate solution of using instead\n\"$hash_base:$file_name\" for $hash, but it caused some errors I didn't\nfeel like debugging. Current diff is also smaller than mentioned\nsolution.\n\nBTW. should we use \"No such tree\" or \"No such directory\".\n\n gitweb/gitweb.perl |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 18e70a3..bb20ed7 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -4445,6 +4445,7 @@ sub git_tree {\n \t\t\t$hash = $hash_base;\n \t\t}\n \t}\n+\tdie_error(404, \"No such tree\") unless defined($hash);\n \t$/ = \"\\0\";\n \topen my $fd, \"-|\", git_cmd(), \"ls-tree\", '-z', $hash\n \t\tor die_error(500, \"Open git-ls-tree failed\");\n@@ -4485,8 +4486,8 @@ sub git_tree {\n \t\tif ($basedir ne '' && substr($basedir, -1) ne '/') {\n \t\t\t$basedir .= '/';\n \t\t}\n+\t\tgit_print_page_path($file_name, 'tree', $hash_base);\n \t}\n-\tgit_print_page_path($file_name, 'tree', $hash_base);\n \tprint \"<div class=\\\"page_body\\\">\\n\";\n \tprint \"<table class=\\\"tree\\\">\\n\";\n \tmy $alternate = 1;\n"},{"id":"92176","messageId":"gc2nq7$fhh$1@ger.gmane.org","threadId":"15757","inReplyTo":"20081002144602.19247.4434.stgit@localhost.localdomain","subject":"Re: [PATCH (BUGFIX)] gitweb: Fix two 'uninitialized value' varnings in git_tree()","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2008-10-02T15:02:30Z","receivedAt":"2008-10-02T15:02:30Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"On Thursday 02 October 2008 16:50, Jakub Narebski wrote:\n\n> gitweb: Fix two 'uninitialized value' varnings in git_tree()\n\nVat's a varning?\n\n-- \nGiuseppe \"Oblomov\" Bilotta\n"},{"id":"92179","messageId":"20081002150859.GQ10544@machine.or.cz","threadId":"15757","inReplyTo":"20081002144602.19247.4434.stgit@localhost.localdomain","subject":"Re: [PATCH (BUGFIX)] gitweb: Fix two 'uninitialized value' varnings in git_tree()","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2008-10-02T15:08:59Z","receivedAt":"2008-10-02T15:08:59Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"On Thu, Oct 02, 2008 at 04:50:04PM +0200, Jakub Narebski wrote:\n> If we did try to access nonexistent directory or file, which means\n> that git_get_hash_by_path() returns `undef`, uninitialized $hash\n> variable was passed to 'open' call.  Now we fail early with \"404 Not\n> Found - No such tree\" error.  (If we try to access something which\n> does not resolve to tree-ish, for example a file / 'blob' object, the\n> error will be caught later, as \"404 Not Found - Reading tree failed\"\n> error).\n> \n> If we tried to use 'tree' action without $file_name ('f' parameter)\n> set, which means either tree given by hash or a top tree (and we\n> currently cannot distinguish between those two cases), we cannot print\n> path breadcrumbs with git_print_page_path().  Fix this by moving call\n> to git_print_page_path() inside conditional.\n> \n> Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n\nAcked-by: Petr Baudis <pasky@suse.cz>\n\n> BTW. should we use \"No such tree\" or \"No such directory\".\n\nI prefer the former.\n"}]}