alpine 3.6
shell weakness #12

4

Weakness Breakdown


Definition:

A shell weakness occurs when a program enables an attacker to execute unexpected commands on the operating system.

Warning code(s):

This causes a new program to execute and is difficult to use safely.

File Name:

mate-sensors-applet/src/mate-sensors-applet-1.18.1/plugins/aticonfig/aticonfig-plugin.c

Context:

The highlighted line of code below is the trigger point of this particular Alpine 3.6 shell weakness.

 
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */

#include <glib.h>
#include <glib/gi18n.h>
#include "aticonfig-plugin.h"

const gchar *plugin_name = "aticonfig";

#define GPU_CORE_TEMP "CoreTemp"
#define MAX_GPUS 4
#define SENSOR_ID_PREFIX "ATIGPU"

static gdouble gpu_temps[MAX_GPUS];
static int num_gpus = 0;

static int ati_get_temps(gdouble temps[], int max_temps)
{
  double temp;
  int read_count;
  int gpu_no = 0;
#ifdef HAVE_STDIO_H
  FILE *aticonfig = popen(ATICONFIG_EXE
      " --adapter=all --od-gettemperature", "r");
  if (aticonfig == NULL) {
    return 0;
  }
  while ((read_count = fscanf(aticonfig, "Temperature - %lf", &temp)) != EOF) {
    if (read_count < 1) {
      getc(aticonfig);
    } 
    else {
      temps[gpu_no] = (gdouble)temp;
      if (++gpu_no >= max_temps) 
	break;
    }
  } 
  pclose(aticonfig); 
#endif
  return gpu_no; 
}

static void ati_update_temps(void)
{
#ifdef HAVE_TIME_H
  static time_t last = 0;
  time_t now = time(NULL);
  /* Only update when more than two seconds have passed since last update */ 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.