summaryrefslogtreecommitdiff
blob: 7de78275904d400d5711ec6999ecb2532b44db42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Index: libcdio-0.76/lib/driver/image/nrg.c
===================================================================
--- libcdio-0.76.orig/lib/driver/image/nrg.c
+++ libcdio-0.76/lib/driver/image/nrg.c
@@ -1173,21 +1173,14 @@ _get_track_green_nrg(void *p_user_data, 
 bool
 cdio_is_nrg(const char *psz_nrg) 
 {
-  unsigned int i;
+  size_t psz_len;
   
   if (psz_nrg == NULL) return false;
+  psz_len = strlen(psz_nrg);
+  /* At least 4 characters needed for .nrg extension */
+  if ( psz_len < 4 ) return false; 
 
-  i=strlen(psz_nrg)-strlen("nrg");
-  
-  if (i>0) {
-    if (psz_nrg[i]=='n' && psz_nrg[i+1]=='r' && psz_nrg[i+2]=='g') {
-      return true;
-    } 
-    else if (psz_nrg[i]=='N' && psz_nrg[i+1]=='R' && psz_nrg[i+2]=='G') {
-      return true;
-    }
-  }
-  return false;
+  return strncasecmp( psz_nrg+(psz_len-3), "nrg", 3 ) == 0;
 }
 
 /*!